DoSomething / gladiator

:guardsman: The DoSomething.org competitions platform.
2 stars 0 forks source link

Update the API for Phoenix-Next requests #399

Closed weerd closed 7 years ago

weerd commented 7 years ago

Phoenix-Next (PN) will be adding a component on the campaign page to allow users to signup for a competition once they affiliate with the campaign. For the time being this component will be a persistent item at the top of the Action page regardless of whether the user is signed up or not.

We need Gladiator to expose a couple things for PN via the API, such as asking if a user is signed up for a contest (making sure to account for a user being in a waiting room OR already moved into a competition). PN will be making a get request to the users endpoint and pass along the following parameters:

/api/v1/users?user=58flongnorthstarid99&campaign_id=1144&campaign_run_id=2234

I believe that's the minimum amount of info Gladiator would need to figure out if the specified user is in a contest, by filtering via the users index endpoint.

Also, we need to make sure that Gladiator checks to confirm a user is not already in a contest (waiting room or competition; but maybe checking against the contest is enough) since PN will for the time being only use local storage in the browser to know if a user signed up for a competition or not. It is very possible that if the local storage is cleared or the user is on a new browser, then they could click to signup for a competition again. Previously, Phoenix-Ashes has a DB table that knew whether a user was signed up or not, so no extra requests would get sent to Gladiator. Since PN for the time being isn't doing that, Gladiator should be double-checking (probs should be doing this anyhoo!).

Here is the work already done on PN to enable making API requests to Gladiator if needed for reference!

sbsmith86 commented 7 years ago

@weerd FYI - we already have this issue for the second half https://github.com/DoSomething/gladiator/issues/396

weerd commented 7 years ago

@sbsmith86 ah cool ok. Thanks for referencing it. I looked in the issues quickly and missed it 😬