diff options
author | Daniel Thompson <daniel.thompson@linaro.org> | 2017-09-11 16:53:38 +0100 |
---|---|---|
committer | Daniel Thompson <daniel.thompson@linaro.org> | 2017-09-11 16:53:38 +0100 |
commit | 4cdfa4f88d190231a6a46a31724c98aabcd3c6ef (patch) | |
tree | 4afd2b75ed3d061b13c5a88fe947520a34438ffb | |
parent | adee2a39c3bdbdb3c7d6483d3fc7e693ca9047bd (diff) |
96btool: Improve search heuristic to select recent topic_id
-rwxr-xr-x | bin/96btool | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/96btool b/bin/96btool index a5a15d9..ad44a32 100755 --- a/bin/96btool +++ b/bin/96btool @@ -183,9 +183,13 @@ class Post(dict): # most recent post_id) latest_topics = client.latest_topics() - # the 0th topic is the freshest and should have the largest - # post id - latest_topic_id = latest_topics['topic_list']['topics'][0]['id'] + # Although the 0th topic is normally the freshest there + # are some conditions where pinned topics are listed at + # the top of the list despite being pretty old (this + # is a particular problem when the user is not logged in) + latest_topic = max(latest_topics['topic_list']['topics'], + key=lambda k: k['last_posted_at']) + latest_topic_id = latest_topic['id'] latest_topic = client._get('/t/{}.json'.format(latest_topic_id)) latest_post_id = max(latest_topic['post_stream']['stream']) |