aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel.thompson@linaro.org>2017-09-11 16:53:38 +0100
committerDaniel Thompson <daniel.thompson@linaro.org>2017-09-11 16:53:38 +0100
commit4cdfa4f88d190231a6a46a31724c98aabcd3c6ef (patch)
tree4afd2b75ed3d061b13c5a88fe947520a34438ffb
parentadee2a39c3bdbdb3c7d6483d3fc7e693ca9047bd (diff)
96btool: Improve search heuristic to select recent topic_id
-rwxr-xr-xbin/96btool10
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'])