Now that I have my database seeded, I started the process of reconstructing my backend with my new information (click here for seeding info and code). I had to pull out all my functions and algorithms that processed firebase and replace them with new algorithms that process my users information and creates an itinerary of their trip for my celery to process.
I ended up changing my model from holding all my user and their transit data in one table to having a user table and a transit_request table.
Since I had the most of my web app done, it was fairly simple to pull out the code that references firebase. My form returns the agency code, route code and stop codes; it was straight forward to process this information to build the user’s itinerary because I am using SQLAlchemy.
As for my celery, I had to rewrite the part as well. Since I had the current stop that my user is at – I start this out as my user’s initial stop. My celery checks the current stop’s times (511 lets you give the stop code and it provides an XML of tons of info). I parse out all the routes and their times into a dictionary with the route number as the key and the value is the list of times. So when I have this dictionary for the current stop, I can get the value for the route code.
I have a special case with Bart, since 511 uses route for different parts of a route – check out here for more info about how I parsed out Bart routes. If there is a comma in the route code that means that there are several codes that that route uses.
If the route is under 3 mins then it does a couple of checks. First it checks if the current stop is my destination stop and if it is then it’ll send the text message and marks this transit request complete. If it is not the destination stop, then it’ll look for the next stop in the itinerary and sets the current stop to the next stop. You can check out my celery code here.
Here is my beautiful json that I send for Bart
I am so close to finishing Rideminder Version 3!