One feature I wanted in TripCaster was the ability to save a trip’s forecast and return to it quickly, without having to enter in the entire trip’s itinerary again. This was why I decided to have the user’s input stored in a query string. So if you went on a 2 day trip to Rome, the querystring would contain “&cities=Rome&cities=Rome”. The idea was that the user could copy the entire URL of the results page then later come back to that same URL to get the same information.
This didn’t work in the initial release however, as the app would take the cities listed in the query string and create a brand new report based on today’s date.
An intuitive solution would be to just use a database and store all generated reports there, but I wanted to keep TripCaster ‘lightweight’.
At first I tried to do the date adjustment on the front end. I figured that we would get a list of the reports, and for each day offset, we would remove a report from the front of the list. When I was nearly finished with the solution I realized that this wouldn’t work as the data in the reports would not be correct. Doing this would show future weather forecasts as closer to the present. I realized that I would have to fix things in the code that called the API, and tell it to change the days to look up according to the day offset.
On pythons end it saves the query string to a variable, calculates the day offset , and for each day offset it would remove a city from the front of the string variable. It would then send this modified string to the results page and give the user the proper weather.