Merge lp://staging/~kai-mast/friends/fix-retweets into lp://staging/friends

Proposed by Kai Mast
Status: Merged
Merged at revision: 247
Proposed branch: lp://staging/~kai-mast/friends/fix-retweets
Merge into: lp://staging/friends
Diff against target: 58 lines (+15/-8)
2 files modified
friends/protocols/twitter.py (+14/-7)
friends/tests/test_twitter.py (+1/-1)
To merge this branch: bzr merge lp://staging/~kai-mast/friends/fix-retweets
Reviewer Review Type Date Requested Status
Robert Bruce Park Approve
Review via email: mp+198019@code.staging.launchpad.net

Description of the change

This branch fixes the truncation of retweets. It also allows to properly support RTs in the future.

Be free to correct my coding style ;)

To post a comment you must log in.
262. By Kai Mast

Tried to removed whitespace in diff

Revision history for this message
Robert Bruce Park (robru) wrote :

So this mostly looks good, but there's a bad idiom you used here that you also did in your previous MP:

58 + if "retweeted_status" in tweet:
59 + shared_status = tweet.get('retweeted_status')

There's just no need for this kind of "look before you leap" logic in python. At worst, it's a race condition, and at best it's inefficient.

What you really want to do is something more like this:

message = tweet.get('retweeted_status', {}).get('text', '') or tweet.get('text', '')

If you do that, then you also reduce the number of calls to _resolve_tco() to 1, meaning you can inline it (meaning it doesn't have to be it's own method anymore).

Also you have "entities = tweet.get('entities', {})" in two different places, needlessly redundant.

review: Needs Fixing
Revision history for this message
Kai Mast (kai-mast) wrote :

But how would I add "RT"-part in this case? (see line 61 and 80)

Revision history for this message
Robert Bruce Park (robru) wrote :

Still better to just have "shared_status = tweet.get('retweeted_status', {}).get('text', '')" and then you can say "if shared_status: message = 'RT ' + message" or something. Testing a dict before pulling a value from a dict is really bad form in python.

Revision history for this message
Kai Mast (kai-mast) wrote :

Okay. I will do that.

Do you want me to inline the other stuff again? I really like small functions; they make the code more readable in my opinion.

Revision history for this message
Robert Bruce Park (robru) wrote :

Not sure right now... I like small functions too but I dislike functions
that only get called once :)

263. By Kai Mast

Simplified code as suggested

264. By Kai Mast

Diff cleanups

Revision history for this message
Kai Mast (kai-mast) wrote :

Okay the diff really is a lot smaller now.

I added an if-clause to fetching the media url. I think otherwise me may run into problems when the picture is not the last entity.

Revision history for this message
Kai Mast (kai-mast) wrote :

we*

Revision history for this message
Robert Bruce Park (robru) wrote :

Ok, this is looking good now just from reading it. I need a bit more time to review it fully, hopefully later today.

Revision history for this message
Robert Bruce Park (robru) wrote :

Kai, thanks for this branch. I merged it with some changes, you should review them here:

http://bazaar.launchpad.net/~super-friends/friends/trunk/revision/247

Note how I managed to achieve the same logic without having to do any dictionary membership tests.

review: Approve
Revision history for this message
Kai Mast (kai-mast) wrote :

Okay that really looks nicer. Thanks for merging.

Just wondering, how often is the friends package for trusty rebuilt? Would be nice to benefit from those changes.

Revision history for this message
Robert Bruce Park (robru) wrote :

It gets rebuilt every 4 hours, except that it doesn't, because of reasons.

So basically you have to ask for it. Right now there's an informal 'freeze' on releases because we're trying to get our automated phone-image testing system at 100% pass rate and we don't want to release *anything* that might inadvertently cause regressions. Over the last couple weeks we've gotten it from something like 80% to 98%, so it should be done soon. Hopefully we might be able to do a friends release this week, barring any catastrophic failures.

Revision history for this message
Robert Bruce Park (robru) wrote :

Kai, if you really need to test a newly built package, you can enable ppa:ubuntu-unity/daily-build and install friends from there (but be sure to disable the ppa before upgrading your system, most of the other stuff in that PPA will hose your system).

Revision history for this message
Kai Mast (kai-mast) wrote :

Okay cool. I just took the friends package from the PPA so nothing else should break.

As far as I see friends is not running in an upstart usersession yet. Is that also something I could tackle?

Revision history for this message
Robert Bruce Park (robru) wrote :

You're welcome to try! I haven't been keeping up with that stuff much myself.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: