Milestones
- Create initial project files
- Add html template to the client folder
- Create mongo models (Team, Player, SyncRecord)
- Create required controllers
- Add method to accept date + steps and update accordingly
- Google Auth and extract daily steps
- API integration testing
- Implement frontend according to the design
- Create Dockerfile and docker-compose.yml
- Deploy into a AWS vm
- User testing
REST API
GET /api/v1/leaderboard/topteams
GET /api/v1/leaderboard/topteams/{teamId}
GET /api/v1/leaderboard/topplayers
GET /api/v1/leaderboard/topplayers/{playerId}
GET /api/v1/leaderboard/topmaleplayers
GET /api/v1/leaderboard/topfemaleplayers
POST /api/v1/sync
- Replaces steps data, recalculates team/solo scores
{
"stepCounts": [
{
"date": "2018-10-12",
"steps": 7500
},
{
"date": "2018-12-12",
"steps": 8500
}
]
}
POST /api/v1/syncmanual
- Update/Add single data point, recalculates team/solo scores
{
"stepCounts":
{
"date": "2018-10-12",
"steps": 7500
}
}
GET /api/v1/playersync
- Retrive scores/steps for a specific player
//Sample output
{
"total_steps": [
{
"_id": "5d31f96c936e5360eaa83c94",
"steps": 5500,
"points": 25,
"date": "2018-11-12T00:00:00.000Z"
},
{
"_id": "5d31ec3d41f5763bf038d9ae",
"date": "2018-10-12T00:00:00.000Z",
"steps": 5500,
"points": 25
}
],
"steps": 11000,
"points": 50
}
Developer Setup
Fork and clone https://github.com/99xt/walk2win.git
Install dependencies
$ cd client
$ npm i
$ cd ../server
$ npm i
Setup enviroment configuration
server
- Setup mongo connection string and the server port from
./server/.env
MONGO_STR=<database_string>
PORT=3003
- Add your contest rules into
./server/constants.js
client
-
Follow steps mentioned here to request an OAuth 2.0 client ID and API key.
-
Add the keys to the relevant
environment.ts
file in locationclient/src/environments
. You can select either prod or dev.
export const environment = {
production: true,
baseApi: '<add_base_api_here>',
client_id: '<add_client_id_here>',
apiKey: '<add_apiKey_here>'
};
Install mongodb and then import sample data
$ cd server
// Enter some rows into data/data.csv
$ npm run initdb
Start the REST API
$ cd server
$ npm run dev
Start the Angular app
$ cd client
$ ng serve -o
Submit a pull request with the new feature
Deployment guidelines
Login to your vm or machine via ssh
$ ssh -i <key-file>.pem <username>@<domain>
Remove existing directory and get a clone from deployment repository
$ sudo rm -rf <repo-name>
$ git clone <repo-url>
Create containers
$ cd <repo-name>
$ sudo docker-compose up --build -d
Initialize db from data.csv
if you are using external mongodb service directly execute intialize.sh
from the host. Otherwise(If you are using dockerized mongo instance), Log in to the container and execute initialize.sh
$ sudo docker exec -it --user=root <container_id> /bin/bash -d
$ cd data
$ ./initialize.sh
License
Made with contributors-img.