Suade Labs Analytics Challenge (Connor Adams)
This is a Flask API that parses .csv
data for a demo shop, for a given date in the format YYYY-MM-DD
Due to the time constraints of this challenge (24 hrs) I had some challenges with the structure of the application. This app is loading the .csv files into memory and directly querying the files using python and some SQL queries brought in from the pandasql python package.
This IS NOT an optimal solution by any means. If I had more time, I would read these .csv files into a MySQL database (preferably through Amazon RDS using an EC2 instance) then parse the data with actual SQL queries. An actual RDMS would help with parsing this data immensely.
To build, Create a VM using Python 3.9 import requirements from
suade_analytics/requirements.txt
And point the configuration class to
suade_analytics/app.py
If using terminal, just run
python app.py
API will be running on http://127.0.0.1:5000/ with the swagger docs on http://127.0.0.1:5000/apidocs
curl -s http://127.0.0.1:5000/get_analytics_report/2019-08-02 | jq
{
"commissions": {
"order_average": 10514893.66,
"promotions": {
"1": 22633010.44,
"2": 19293679.09,
"3": 22016151.23,
"4": 15290844.79,
"5": 13743272.78
},
"total": 92976958.32
},
"customers": 10,
"discount_rate_avg": 0.13,
"items": 3082,
"order_total_avg": 164998295.76,
"total_discount_amount": 150457385.36
}