AbodeSaafan / pickup

Project Pickup is the SOTI intern project for 2017/18. The idea is an app that helps you create and find local pick up basketball games.
GNU General Public License v3.0
1 stars 1 forks source link

Create New Game - Create a new game based on the info input by the user #140

Open GitGeminiano opened 6 years ago

GitGeminiano commented 6 years ago

Create a new game based on the info input by the user by calling our create game API in the backend.

GitGeminiano commented 6 years ago

What is left:

1) Gather info for Enforced_params, Time_created, Players_added. 2) Check final start and end time calculation. 3) Check jwt failure when create game button is clicked.

cc: @AbodeSaafan

GitGeminiano commented 6 years ago

The jwt failure happens due to validation issues on the server side (time duration needs to be checked, see logs).

AbodeSaafan commented 6 years ago

@GitGeminiano The general validation is failing, because the parameters sent are not as expected, for instance, I see that when I try to use the UI to create a game it's not properly sending the start time (it sends -1677842656). But to be sure, can you send me a request that you are sending to the server.

You can do this by going to the debug endpoitnt https://pickup-app-api.herokuapp.com/api/verysecureandsecretlogs/tempdevpassword after you sent the request and then send me the body for the call.

GitGeminiano commented 6 years ago

@AbodeSaafan The request in #148 comes from Android and this one comes from Heroku: {"level":"verbose","message":"POST /api/games. Params: {}. Query: {}. Body: {\"age_range\":[18,25],\"description\":\"My description\",\"duration\":1,\"enforced_params\":[\"age\",\"gender\",\"player\"],\"gender\":\"m\",\"jwt\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNCIsImVtYWlsIjoiYTEyMzRAaG90bWFpbC5jb20iLCJpYXQiOjE1MjcwNDE1MzYsImV4cCI6MTUyNzA0MjQzNn0.XvQJbbx_MgcK87CkQpApXt5CeNE3PceVak846Vx_HtE\",\"location\":{\"lat\":-0.000008316087718895915,\"lng\":-0.000013913959264755249},\"location_notes\":\"My location notes\",\"max_skill\":8,\"min_skill\":2,\"name\":\"My game name\",\"start_time\":1,\"total_players_required\":2,\"type\":\"serious\",\"userId\":4}","timestamp":"2018-05-23T02:15:00.175Z"}

and the error we get is "400 Error: or: param.trim is not a function"

AbodeSaafan commented 6 years ago

@GitGeminiano I was going to make the change from min/max skill to skill offset but it looks a bit complex right now for me to do since I haven't reviewed/saw your code yet. But, I see that you're using game model to create a game request, the game model doesn't apply so well in this case. Do we have to use it? I think creating the request right with just using the CreateGameRequest class should be good enough and anything we need to add, we can add there.

GitGeminiano commented 6 years ago

@AbodeSaafan I made the changes above. We need it to hold some info we will not use in the final request. For example: min skill and max skill are not used in the request, but are needed to get skill offset. I can create another object to hold this type of information if the Game Model is needed for other purposes.

I understand, it may be a big task to review the code, but I broke the changes into many commits to facilitate the work. Keep in mind that some clean up is needed. Let me know if you have any more questions.

AbodeSaafan commented 6 years ago

@GitGeminiano The skill offset is only a single integer sent to the server which will generate the min and max skill. If a user's (self-selected) skill level is 4 for example, and they choose a skill offset of 1, that is to say they are comfortable playing a serious (this option should only be required for serious games) with players ranging from skill 3-5.

That's fine, just set the review to me whenever you're ready.

radhika2896 commented 6 years ago

@GitGeminiano I am failing review for this because some values are not being sent correctly to the db, after creating a game. 1) The total_players_required and total_players_added are not storing the correct value. 2) The start time and end time are not storing the correct value. 3) The min skill and max skill are not storing the correct value.

I am assigning this issue back to you.

GitGeminiano commented 6 years ago

If we use long for time in the app, the create game API fails the "ensureGameIsValidToBeCreated" step. start time on app: 1528946760000 final time on app: 1528947000000 duration: 240000 Error: The game you are trying to create can not be created because the time conflicts with another game you have created. Log: {"level":"verbose","message":"POST /api/games. Params: {}. Query: {}. Body: {\"age_range\":[20,30],\"description\":\"ttt\",\"duration\":240000,\"enforced_params\":[],\"gender\":\"f\",\"jwt\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiOSIsImVtYWlsIjoiY2dAZ21haWwuY29tIiwiaWF0IjoxNTI4OTQ2NzE1LCJleHAiOjE1Mjg5NDc2MTV9.0YVKt3WFeb7DreoY0rxbJxB15hMc8hXqw3fbBEpq1GQ\",\"location\":{\"lat\":37.421998031845064,\"lng\":-122.08399968221784},\"location_notes\":\"loca notes\",\"name\":\"asasasasass\",\"skill_offset\":9,\"start_time\":1528946760000,\"total_players_required\":20,\"type\":\"serious\"}","timestamp":"2018-06-14T03:28:13.411Z"} {"level":"info","message":"GET /api/verysecureandsecretlogs/tempdevpassword","timestamp":"2018-06-14T03:28:40.248Z"}

AbodeSaafan commented 6 years ago

That's because you are creating a game in the span of another game you have already created, try a different account to create the same game or different timing. Also it seems that you're sending the time in MS where I'm pretty sure the API takes the time in S.

On Wed, Jun 13, 2018, 23:29 Christian notifications@github.com wrote:

If we use long for time in the app, the create game API fails the "ensureGameIsValidToBeCreated" step. start time on app: 1528946760000 final time on app: 1528947000000 duration: 240000 Error: The game you are trying to create can not be created because the time conflicts with another game you have created. Log: {"level":"verbose","message":"POST /api/games. Params: {}. Query: {}. Body: {"age_range":[20,30],"description":"ttt","duration":240000,"enforced_params":[],"gender":"f","jwt":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiOSIsImVtYWlsIjoiY2dAZ21haWwuY29tIiwiaWF0IjoxNTI4OTQ2NzE1LCJleHAiOjE1Mjg5NDc2MTV9.0YVKt3WFeb7DreoY0rxbJxB15hMc8hXqw3fbBEpq1GQ","location":{"lat":37.421998031845064,"lng":-122.08399968221784},"location_notes":"loca notes","name":"asasasasass","skill_offset":9,"start_time":1528946760000,"total_players_required":20,"type":"serious"}","timestamp":"2018-06-14T03:28:13.411Z"} {"level":"info","message":"GET /api/verysecureandsecretlogs/tempdevpassword","timestamp":"2018-06-14T03:28:40.248Z"}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AbodeSaafan/pickup/issues/140#issuecomment-397159039, or mute the thread https://github.com/notifications/unsubscribe-auth/ATh-bIWfSizw07Oh6kIWkti0glz0JKPPks5t8di1gaJpZM4Tfx5i .