Made using FastAPI and mongodb. Reason to chose mongodb is because it offers fast read speed for large data sets. I chose FastAPI because function in FastAPI are async, meaning it won't block the request thread while the interpolation is running.
- Clone the repo
- Create
data
folder in the root directory with store-status.csv, menu-hours.csv, and bq-results.csv inside it. - Setup environment.
- Run
python main.py db
to populate the database. - Run
python main.py
to start the server.
This endpoint will trigger the report generation. It will return the report id. The report will be generated in the background.
This endpoint will return the report. If the report is not ready, it will send response with status being running
. If the report is ready, it will send response with status being complete
and the report data.
Interpolation basically is a way to estimate the value of a function between two known values. In this case, we had to get the store's for every interval. I am using linear interpolation to estimate the value between two known values. The formula is:
y = y1 + (x - x1) * ((y2 - y1) / (x2 - x1))
Where x
is the time, y
is the store's status, x1
and x2
is the time of the known values, y1
and y2
is the store's status of the known values.
Uptime is calculated by counting the number of up
status in the store's status. The uptime is then divided by the total number of store's status. The formula is:
uptime = (up_count / total_count)
- Add test
- Add more error handling
- Cache the report data