Reconstructing Back & Front-end

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.

My dog River’s tail is showing

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.


Once I got my backend working, I started working on passing data from my database to my front end so I can display markers for each route’s stops. I decided to pass the different agency information along with my homepage. When the user selects the agency, I have an event listener on that drop down menu to make a ajax call to my server to get all the routes for that agency. When the user selects a route, there is another event listener that makes another ajax call to get all the stops and it creates the markers on the map. You can check out my javascript and server file.


Here is my beautiful json that I send for Bart


I am so close to finishing Rideminder Version 3!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s