Merge lp:~robru/friends/since_id into lp:friends
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ken VanDine | ||||
Approved revision: | 158 | ||||
Merged at revision: | 160 | ||||
Proposed branch: | lp:~robru/friends/since_id | ||||
Merge into: | lp:friends | ||||
Diff against target: |
505 lines (+250/-34) 6 files modified
friends/protocols/twitter.py (+48/-25) friends/tests/test_cache.py (+69/-0) friends/tests/test_identica.py (+12/-3) friends/tests/test_twitter.py (+44/-5) friends/utils/base.py (+1/-1) friends/utils/cache.py (+76/-0) |
||||
To merge this branch: | bzr merge lp:~robru/friends/since_id | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ken VanDine | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+152315@code.launchpad.net |
Commit message
Start using since_id= on Twitter API requests. (LP: #1152417)
This was accomplished by implementing two new classes, and ended up
simplifying some of the RateLimiter code as a side effect.
The first new class is called JsonCache. It is a subclass of dict,
which attempts to populate it's initial state by reading in a json
text file at a configurable location, and also adds a new "write()"
method that dumps the json back out to the same location. This class
was a generalization of what we were already doing inside the
RateLimiter, so it should not be considered a "new feature" if we are
going to butt heads with today's feature freeze.
The second new class is a subclass of JsonCache, which enforces that:
A) keys may not contain slashes, to avoid it getting polluted with
every search term ever searched for, or every message that's ever been
replied to ever, it only observes the values of the "main" streams,
such as "messages", "mentions" and "private", although those values
are not hardcoded so it's flexible to adapt to new streams in the
future.
B) values must be ints (tweet_ids), and values can only be
incremented. This is so that we can easily just throw every observed
tweet_id into the cache, and it only records the largest (newest) one.
The end result is that we now have two new files located at
~/.
~/.
that we have ever seen for each of the streams that we publish to.
These values are then consulted to form the since_id= argument to
several of Twitter's API endpoints, which solves bug #1152417.
As an added bonus, this also greatly reduces our network usage because
we are no longer redownloading duplicate messages over and over, so if
there are no new messages, Twitter is now returning an empty list of
Tweets rather than a large list of stale tweets.
This commit includes full test coverage for all new code.
PASSED: Continuous integration, rev:158 jenkins. qa.ubuntu. com/job/ friends- ci/3/ jenkins. qa.ubuntu. com/job/ friends- raring- amd64-ci/ 3//console
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild: jenkins. qa.ubuntu. com/job/ friends- ci/3//rebuild/?
http://