Demo application made for a tech assessment
- Clone repo
git clone git@github.com:KaitCrawford/Top-scorers.git - Create ve
python3.10 -m venv ve - Activate ve
source ve/bin/activate - Install requirements
pip install -r requirements.txt - Run migrations
python src/migrations_0001.py
- To run script:
python -m src.top_scorers input_file.csv - To run api:
fastapi run src/api.py
- GET "/" shows all scores in the database
- GET "/user_scores/?first_name=&second_name=" shows the details in the db for the user with the given first name and second name (case insensitive, 404 if none exists)
- GET "/top_scorers/" shows the details of all users with the highest score
- POST "/user_scores/" with json body of {"first_name": "", "second_name": "", "score": } will create or update the given user score in the database
- Example authentication implementation is commented out in the api.py file.
- The top_scorers.py script only returns the max score of the users in the given input file, rows in the database are not considered.
- Adding a score with the same first name and second name as an existing row will update the existing row, not create a new row. This check is case insensitive. This behaviour is consistent regardless of if the score is added using the script or the api endpoint
- More notes can be found in comments starting with "NOTE"
- Install requirements
pip install -r requirements-dev.txt - Run tests
pytest