Code Monkey home page Code Monkey logo

pitch_battles_be's Introduction

pitch_battles_be's People

Contributors

clairebvs avatar dmeskis avatar

Watchers

 avatar

pitch_battles_be's Issues

BE - Fix classes endpoint

Currently the endpoint for posting a user class is
api/v1/users/:id/class

Change this to be
api/v1/users/:id/class

BE - Create UserGames Join Table

Create a join table linking Users/Games
A user should have many games and games belong to many users
Attributes:

  • id
  • game_id
  • user_id

BE - Endpoints: Get a Users Games

As a user,
if I sent a GET request to api/v1/users/:id/games,
it returns the following response with a 200 status code:

{
data: {
"id": <user_id>,
"type": ,
"attributes": ,
"games": {
"data": [
{
"id": <game_id>,
"type": "Game",
"attributes": {

}
}
}
}

BE - Create Badges Table

Create a badges table, badges should include the following properties

  • id
  • name
  • description (e.g. "Play 25 games")

BE - Create Class Model

Create a class model
A class should have the following attributes:

  • id
  • name (Ms. Meskis's band class, Orchestra, etc)
  • class_key (Randomly generated key for allowing students to gain entry to the class)

BE - Endpoints - Post Login

POST api/v1/login

request should contain the following
{
email: [email protected],
password: password
}

response is either 200 ok
{
"auth_token":
}

OR

400 Bad info

{
"error": "Incorrect credentials"
}

BE - Endpoints: Add a user to a class

As a user,
if I wish to add myself to a class,
I make a POST request to api/v1/user/:id/classes
with the following body:

{
class_key: <class_key>
}

If the request is successful, respond with the following and a 200 status code:
{ "success": "Successfully joined ${class_name}!" }

If the request is unsuccessful, response with the following and a 400 error:
{ "error": "Class not found." }

Build dashboard endpoint

Build a dashboard endpoint that pulls down EVERYTHING a user has

Stuff we need:
All achievements/badges
Fastest times
Total games played
Last game played
Class id's and names

BE - Implement Caching

Install redis-rails and find a way to implement caching on the API side of things.

Examples:

  • Cache badges until a user posts a new game
  • Cache user games until a post is made to games

BE - Endpoints: Create a user

post /api/v1/users

As a user,
I send the following request:

{
email: “[email protected]”,
first_name: “billy”,
last_name: “bob”,
role: 0,
password: “password”,
password_confirmation: “password”
}

All fields are required.
If post is successful, returns the following response with status 200:
Response
{
“success”: “Account successfully created”
}

If post fails, returns the following response with a 400 error:
{
"error": "Account creation failed. Please try again."
}

BE - Create Game Model

Create a game model
Games should have the following attributes:

  • id
  • total_duration
  • level_one_duration
  • level_two_duration
  • level_three_duration
  • level_four_duration
  • remaining_life

*Subject to change, check in with Kevin

Test all models have attributes

Forgot to write tests for validating that models possess certain attributes, revisit the following models and implement these tests:

  • User
  • Klass
  • Game

BE - Create badge analysis logic

Once we have created our badges, create a service that runs every time a game is posted that analyzes whether or not a badge has been earned and then updates the user badges table correspondingly

Add top times to user model:
Per level and top overall

In post game processing,

BE - Create User Model

Create a user model
A user should have the following properties

  • Id
  • email
  • first_name
  • last_name
  • role (0..2)
  • password
  • avatar (default 1)

BE - Create Relationships Join Table

Create a join table for joining students to teachers
Attributes:

  • id
  • teacher_id
  • student_id

User with teacher_id requires a role of 1 ("teacher")
user with student_id requires a role of 0 ("student")

Add endpoint for deleting a user from class

DELETE api/v1/user/:id/classes

Delete a user from a class
Authorize that user is teacher of class by using @current_user and seeing if role is 1 and class relationship exists

BE - Endpoints: Post a Game

POST /api/v1/games

As a user,
I send the following request with the following fields to post a completed game:

{
email: “[email protected]”,
total_duration: 1000,
level_one_duration: 400,
level_two_duration: 200,
level_three_duration: 200,
level_four_duration: 200,
remaining_lives: 0..3
}

Email is REQUIRED!
Total duration can be calculated front-end or back-end
If a level duration is null, consider that level incompleted.
Level duration is in milliseconds
Remaining lives must be in the valid range of maximum life (Ask Kevin)

If post is successful, returns the following response with status 200:
Response
{
data: {
id: 3,
type: "Game",
attributes: {
total_duration: 1000,
level_one_duration: 400,
level_two_duration: 200,
level_three_duration: 200,
level_four_duration: 200,
remaining_lives: 2
}
}
}

If post fails, returns the following response with a 400 error:
{
"error": "Game post failed. Check error logs."
}

Setup JWT

Setup a JWT auth system for users

Update User Patch to use @current_user

Currently the endpoint for patching a user uses a lookup, with the :id

  1. Change the route of the endpoint to not require a user ID.. (Maybe)
  2. Set user to @current_user

BE - Endpoints: Get all user badges

As a user,
I send a GET request to api/v1/users/:id/badges

Upon a successful request I get the following response (200):

{
data: {
id: <user_id>,
type: "User",
attributes: { <user_attributes> },
badges: { }
}
}

Add user_id to game

Create database migration that adds a one to many relationship for teacher games

BE - Endpoints: Get User Data

As a user,
I send a GET request to api/v1/users/:id,
if it is a valid user id, the server responds with the following:
{
"data": {
"id": "1",
"type": "user",
"attributes": {
“email”: “[email protected]”,
“first_name”: “billy”,
“last_name”: “bob”,
“role”: “student”,
“badges”: {
“level_1_badge”: “true”,
“level_2_badge”: “false”,
etc. etc.
}
}
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.