Please sign in to comment.
Changing twitter.py to look at the most recent two statuses.
Previously, we only looked at one status. However, BeijingAir occasionally posts two statuses in quick succession, with the final one being a summary of recent air quality, rather than a new update. If the /tasks/updateStatus cron job encountered that status, it would attempt to parse it and add it to the database, but it would miss the real update for that hour. This typically happens at noon. Now that we have de-deplicating code, it's ok to just always get the most recent two statuses. We don't have to worry about readding the previous one during the hours that only have one update, and we need to make sure we get the second-to-last update in those hours that have the summary tweet.
- Loading branch information...
|@@ -1,8 +1,12 @@|
|- return simplejson.load(urllib.urlopen("http://api.twitter.com/users/show/15527964.json"))['status']['text']|
|+ statuses = simplejson.load(urllib.urlopen("http://api.twitter.com/1/statuses/user_timeline/beijingair.json?count=2"))|
|+ cleanStatuses = |
|+ for status in statuses:|
|+ return cleanStatuses|
|# The following line is for testing on my localhost, which is in Beijing and therefore Twitter is blocked.|
|# return "03-05-2010; 13:00; PM2.5; 88.0; 55; Moderate // Ozone; 43.3; 36; Good"|