Schema changes: add a synthetic key on stop_route_direction, and
reference that in stop_event, for more efficient grouping. Add derived
table stop_interval for more efficient queries, and define function
generate_stop_intervals() to populate it based on the data in stop_event.
Code changes to support the new schema.
Add pkey to stop_event.
Basic logging (to the database) of each run of the loop. The eventual
intention is to use this to exclude periods of downtime from our bus
frequency calculations.