gtracy/SMSMyBus — pull request #12 by epaulson (2012-02-16 23:20:32+00:00)
Title: Parking special events

In addition to the real-time stats about a ramp, also include information on the special events/pay on entry for a parking location.

The data comes from here:
http://www.cityofmadison.com/parkingUtility/calendar/

and is scraped by this:
https://scraperwiki.com/scrapers/madison_wi_special_event_parking/

Data is read out of the scraper and returned in JSON with this:
https://scraperwiki.com/views/madison_parking_special_events_api/

getparking now loads that JSON and sticks it in memcache. The scraper only runs once a day, and the JSON includes a timestamp to give SMSMyBus API some hint as for how long to cache the scraper data.

When a request for parking status comes in, the special event data is pulled from memcache, and for each event, we see if it is in special event, pay on entry mode, or if will be soon (by default, within the next 3 hours, though that can be specified for up to the next 24 hours). If so, a hash for the event is inserted into the JSON response for that ramp.

To assist in testing, the "current time" (by which we determine if there is a special event now or in the near future) can also be passed in via a parameter to the API. That way, if you're testing on a tuesday and there are no events scheduled until Thursday, you can lie and tell the API that it's Thursday.

I also wrote some basic documentation and updated the API HTML to include it.