load overviews from cache
to be nice and avoid hammering the server during developmentnntp
parent
d43b3f9979
commit
932e39ac0a
|
@ -97,7 +97,7 @@ class BBJNews(object):
|
||||||
"admins": [],
|
"admins": [],
|
||||||
}
|
}
|
||||||
|
|
||||||
self.connect()
|
#self.connect()
|
||||||
|
|
||||||
#try:
|
#try:
|
||||||
# self.user = self("get_me")["data"]
|
# self.user = self("get_me")["data"]
|
||||||
|
@ -486,8 +486,15 @@ class BBJNews(object):
|
||||||
author_id = thread["author"]
|
author_id = thread["author"]
|
||||||
print(usermap[author_id]["user_name"])
|
print(usermap[author_id]["user_name"])
|
||||||
"""
|
"""
|
||||||
response, count, first, last, name = self.conn.group(self.group)
|
if os.path.exists("overview_cache.bbj.json"):
|
||||||
|
with open("overview_cache.bbj.json", "rt") as f:
|
||||||
|
overviews = json.load(f)
|
||||||
|
else:
|
||||||
|
response, count, first, last, name = self.conn.group(self.group)
|
||||||
|
|
||||||
|
response, overviews = self.conn.over((first, None))
|
||||||
|
with open("overview_cache.bbj.json", "wt") as f:
|
||||||
|
json.dump(overviews, f)
|
||||||
|
|
||||||
# overviews is a list of (article_number, overview) tuples,
|
# overviews is a list of (article_number, overview) tuples,
|
||||||
# one for each article.
|
# one for each article.
|
||||||
|
@ -499,10 +506,6 @@ class BBJNews(object):
|
||||||
# :bytes - the number of bytes in the article
|
# :bytes - the number of bytes in the article
|
||||||
# :lines - the number of lines in the body (deprecated)
|
# :lines - the number of lines in the body (deprecated)
|
||||||
|
|
||||||
response, overviews = self.conn.over((first, None))
|
|
||||||
with open("overview_cache.bbj.json", "wt") as f:
|
|
||||||
json.dump(overviews, f)
|
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# build up a map of message references
|
# build up a map of message references
|
||||||
# we use a disjoint-set data structure
|
# we use a disjoint-set data structure
|
||||||
|
|
Loading…
Reference in New Issue