Closed sidetrackedmind closed 2 years ago
After discussing with the team, we decided:
get_data_frame
functionI updated the download_arrival_data
in metrics-api.py. The function is hard coded for now but it creates a ArrivalHistory object, calls get_data_frame
and then renames some fields and adds others before sending the .csv to the user.
My latest commits add the following:
download arrival data
button to routesummarydownload_arrival_data
function in metrics-api.py to fetch request arguments and download the user selected route, dates, direction, and timesSee below screenshot of download arrival data button:
I'm pulling the trigger on this 🥳
Fixes #25
Proposed changes
The main goal of this pull request is to create a proof of concept for allowing a user to download arrival data for a particular route + date.
This pull request has 3 main changes:
Adds a function to the ArrivalHistory class - save_date_for_user_download. This function runs get_by_date and then reformats the results into a more user friendly dataframe. The dataframe has renames the raw data headers as follows:
Adds a enpoint @app.route('/api/arrival_download', methods=['GET']) to metrics-api flask app. In this proof of concept the route does not take any parameters and it always downloads the same route+date. The flask endpoint calls a function download_arrival_data that uses save_date_for_user_download for route='4' and date='2022-03-10' to create a dataframe and send the dataframe via flask make_response.
Adding very basic placeholder code for a Download frontend tab. This may be all wrong but it gets the job down for testing 😄 .
Screenshot