These files where directly called from the api endpoints. Now all
functoins have been replaced with a controller interfacing to the
endpoint and a repository file for each of the functions.
Moved all logic related to lotteryAttendees, lotteryWinners and
prelotteryWines into each their repository and controller.
Now only holds draw, archive and get archived lotteries.
Moved the same functionality out from lottery.js and simplified a bit.
Now the backend also sends with wines to pick from.
When hitting the controller we check that the user is the next user in
line.
Changed so get attendees no longer is done in two endpoints, now we use
req.isAuthenticated() to check if we want to return full or minimal json
data about each attendee.
Winner controller replaces a lot of what happens in retrieve did for
aggregating when and what had been won. Now this is more clearly defined
in winner.js.
Also leverage mongo's query more than sorting and aggregating data like
previous implementation where a lot happened in js.
Rewrote everything that happened in history to better take advantage of
monogdb instead of doing everything in js.
Our endpoints become:
- /winners - getAll w/ includeWines and sort query params.
- /winners/latest - latest winners grouped w/ includeWines query
params.
- /winners/by-date - all winners grouped by date w/ includeWines and
sort.
- /winners/by-date/:date - get winners per epoch or string date.
- /winners/by-name/:name - get winner by name parameter w/ sort for
wins direction.
Moved from Redis lists to sorted lists by timestamp for better
pagination. Now we have better interfacing w/ page & limit. History now
also returns the total record count.