bostontraintrack icon indicating copy to clipboard operation
bostontraintrack copied to clipboard

Show alerts for filtered routes

Open abetusk opened this issue 9 years ago • 0 comments

It would be nice to have relevant alerts show somewhere. Maybe this should be an extra toggle (off to the right?). Maybe some type of exclamation point or a modified icon?

Here's a sample script to grab the relevant alerts:

#!/bin/bash

api_key=`cat abetusk.key`
#wget --quiet 'http://realtime.mbta.com/developer/api/v2/alertheaders?api_key=wX9NwuHnZU2ToO7GmGR9uw&format=json' -O -
json=`wget --quiet 'http://realtime.mbta.com/developer/api/v2/alertheaders?api_key='$api_key'&format=json' -O -`

for id in `echo "$json" | jq '.alert_headers[].alert_id'`
do

  q='http://realtime.mbta.com/developer/api/v2/alertbyid?api_key='$api_key'&id='$id'&format=json'
  echo "$q"
  r=`wget --quiet "$q" -O -`

  echo "$id"
  echo "$r" | jq .
done

The basic idea is to have another persistent node server that polls the MBTA site to update it's local alert structure, then pushes either the complete state or deltas to connected clients. The number of alerts is so low that it might just be worth pushing everything every 30-60s.

In terms of communicating the alert, there are a few options:

  • Have the alert appear as a banner (maybe that 'rolls' through the different alerts?) on the bottom.
  • Annotate the markers (buses, subways, commuter rails, stops, etc.) that are affected (with another marker at the exact Lat/Lon position, at a higher height but offset to a corner).

Some things to take into account:

  • Not all alerts are created equal. They are of varying severity from Minor, Moderate to Severe. We might want a different icon for those states.
  • Not all alerts are current. They could be for service changes in the future.
  • Some alerts affect stops, some affect routes. As far as I can tell, if there is a field called stop_name in the services array, then it affects stops (and routes), otherwise it affects routes.
  • The text of the message might indicate where the problem is occuring, which might be useful information to communicate (for example "Green Line experiencing minor delays due to a signal problem at North Station." might want a 'signal problem' icon at North Station).
  • The text description of the alert might be consistent enough to group easily.

NOTE: as of this writing, some queries return a '500: Internal Server Error' on the 'alertbyid' call, so the server will have to be robust enough to no bork on these types of errors. We should probably have it retry until it succeeds (to a maximum of retries).

abetusk avatar Dec 11 '14 03:12 abetusk