Application to track the results of Scott Logic Newcastle's 2018 World Cup Sweepstake
This is a sweepstake competition which will run alongside the 2020 Euros, but with a twist: Players will be drawn 5 teams from a hat, the first 2 teams will be the "goal" teams, the subsequent 3 teams will be the "outcome" teams. The team names will then be returned to the hat for the next player. They will also be asked to predict the total goals that will be scored over the competition.
During the competition points are rewarded as follows:
- 1 Point for every goal scored by a "goal" team.
- 3 Points for every win achieved by an "outcome" team.
- 1 Point for every draw achieved by an "outcome" team.
At the end of the competition the player with the most points will claim the top prize. In the even of a tie, it will come down to whichever player guessed closest to the correct number of goals (under or over).
During the competition this application will display the teams picked by each player, along with the total goals they predicted and their current points tally. It will also display the total goals, wins and draws for each team along with the actual current total goals.
The app is fairly barebones as it was thrown together quite quickly to be ready in time for the cup, and then once again to be ready for the Euros on a new platform.
The UI is a standard React (no Redux or other addons/middleware) app. It is served by an express app running as a cloud function on Google Firebase backed by Firestore.
The data is served by: http://api.football-data.org/ which will be updated during the competition.
- Clone this repository.
- Run
npm installin the root. - Install the firebase cli with
npm install -g firebase-toolsenabling global use of the firebase command. - Grab your API key from football-data.org. Run
firebase functions:config:set footballapi.key="THE API KEY" - Run
npm run serveto run the firebase emulators for hosting, firestore and functions.- Functions will live reload but hosting will require
npm run buildto be run from/hostingto update.
- Functions will live reload but hosting will require
- Run
local:addplayersto add some example players for the application.
The database is driven by Google Firestore. and the structure is as follows:
|
+-- competition
| +-- fixtures
| +-- teams
| +-- lastApiLookup
+-- players
| Collection.document | Usage |
|---|---|
| competition.fixtures | Data of all fixtures past and present for the tournament |
| competition.teams | Data of all the teams in the tournament and whether they are eliminated |
| competition.lastApiLookup | The last time fixture data was pulled from the API in ISO 8601 |
| players | Data of all the players in the sweepstake. |
The players documents are in the format:
{
name: "Player name",
goalsPredicted: 60,
teams: {
goals: [country1, country2],
outcomes: [country3, country4, country5]
}
}
The last-api-lookup document is in the form
{ lookupTime: "2014-09-08T08:02:17-05:00" }