Flight Log Version 2.0: Flight Historian

It’s been over three years since I began working on my flight log. In that time, it’s gone from an interesting side feature of my Portfolio to a major project large enough to stand on its own. For the past month, I’ve been spending my free time working on spinning it off into its own site. Now announcing:

Paul Bogard's Flight Historian

http://www.flighthistorian.com/

Along with the new domain, I’ve worked on adding a bit of new functionality to the site.

Premium Economy

Screenshot 2016-01-19 23.21.53

I started the flight log with the capability for three classes: first, business, and economy. (I’ve then somehow managed to never fly business class.) Over the last few years, many airlines have been adding a class of service that’s a little better than a standard coach class seat, but not quite to the level of a business class seat. At the very least, premium economy seats offer a few inches more legroom than a standard coach seat, and occupy a favorable part of the plane (often between the economy bulkhead and the over-wing exit rows). Many airlines are now charging for these seats or reserving them for passengers with frequent flyer status.

The experience is different enough from standard economy, and present on enough airlines, that I feel comfortable tracking premium economy as its own class.

Fortunately, I’ve been scanning and saving my old boarding passes for the past few years, so I was able to determine which of my recent economy flights were actually premium economy.

IATA Codes

You may be familiar with the three-letter airport code you see printed on your boarding passes (for example, LAX for Los Angeles). This three-character code is assigned by the International Air Transport Association (IATA).

Airports aren’t the only thing that the IATA has codes for; they also have two-character codes for airlines (DL for Delta) and three character codes for aircraft types (M80 for MD-80), both of which you may see when booking flights online.

Screenshot 2016-01-30 23.52.29

The IATA technically has one-letter codes for travel classes, but most airlines use their own fare codes instead. However, many travelers still informally use these IATA codes (F for first, J for business, Y for economy) to refer to the class they’re flying.

I’ve added these IATA codes to all airlines (including operators and codeshares), aircraft types, and travel classes.

Faster Loading Speeds

My old flight log often took a long time to load. For a while, I’d been assuming that I was simply hosting my site on a slow webserver.

I realized there was more of a problem when doing all these updates required me to spend a lot of time with the site running on my local computer. Since I was the only user, it shouldn’t have been slow – yet it was.

Looking at my local server logs, I noticed that some pages were taking nearly seven seconds to render, and had thousands of database queries.

Speed

[Technical explanation – feel free to skip this paragraph.] It turned out that in some code that I used in a lot of places, I was inadvertently triggering a few database queries (due to ActiveRecord associations that I’d forgotten were actually part of another table) within each iteration of a for loop.  By explicitly setting up my own monolithic SQL query with the joins, I was able in many cases to do one big query rather than thousands of tiny queries. Additionally, I’d broken some of my Ruby on Rails code into too many partials, which was driving up the view rendering time substantially. Combining a few of the partials into one helped out quite a bit.

Essentially, by optimizing some of my code, I was able to make most of the Flight Historian’s pages load much faster than they did in the old Flight Log. In particular, the home page (“root”), which is the page most people will see first, went from loading in 3.74 seconds to loading in 0.20 seconds – about 18 times faster!

Change Log

Front End

  • Separated the Flight Log from my Portfolio into its own website, renamed the Flight Log to the Flight Historian, and gave it a new domain (http://www.flighthistorian.com/)
  • Created a new favicon
  • Added premium economy to list of travel classes
  • Added IATA codes to airlines (including operators and codeshare airlines), aircraft families, and travel classes
  • Added aircraft illustrations to most aircraft family pages
  • Added aircraft name to Show Flight
  • Added tables of operators to Show Aircraft Family, Show Airport, Show Airline, Show Tail Number, Show Route, and Show Travel Class views
  • Moved the list of flights to the end of many views, but added link to flight list immediately under the map of flights
  • Added region selectors to many more maps
  • Updated all maps to use the same color schemes
  • Added country flags to tail numbers
  • Minor typo fixes

Back End

  • Rehosted Flight Historian on Heroku
  • Upgraded from Rails 3.2.11 to Rails 4.2.3
  • Upgraded from Ruby 1.8.7 to Ruby 2.2.4
  • Converted database from MySQL to PostgreSQL
  • Converted stylesheets to SCSS
  • Converted Airlines from an attribute of Flights to a full model
  • Converted Aircraft Families from an attribute of Flights to a full model
  • Rewrote the Flight Historian’s Great Circle Mapper map generating functions to be more consistent
  • Optimized database queries and page rendering to make pages load faster
  • Added boarding pass data column to Flights table
  • Added date sanity check to warn if departure date and UTC departure date/time are too far apart
Advertisements

One thought on “Flight Log Version 2.0: Flight Historian

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s