Add view count to each thread (#53)

This commit is contained in:
Dave Gallant
2019-12-17 23:04:27 -05:00
committed by GitHub
parent 1af0556045
commit 2e507c1bfb
7 changed files with 23 additions and 17 deletions

View File

@@ -1 +1 @@
0.3.3
0.3.4

View File

@@ -116,6 +116,9 @@ def threads(limit, forum_id):
+ get_vote_color(thread.score)
+ Fore.RESET
+ "[%s] %s" % (thread.dealer_name, thread.title)
+ Fore.LIGHTYELLOW_EX
+ " (%d views)" % thread.total_views
+ Fore.RESET
)
click.echo(Fore.BLUE + " {}".format(thread.url))
click.echo(Style.RESET_ALL)

View File

@@ -1,10 +1,11 @@
# pylint: disable=old-style-class
class Thread:
def __init__(self, title, dealer_name, score, url):
def __init__(self, title, dealer_name, score, url, total_views):
self.dealer_name = dealer_name
self.score = score
self.title = title
self.url = url
self.total_views = total_views
def __repr__(self):
return "Thread(%s)" % self.title

View File

@@ -29,6 +29,7 @@ def parse_threads(threads, limit):
dealer_name=topic["offer"].get("dealer_name"),
score=calculate_score(topic),
url=build_web_path(topic.get("web_path")),
total_views=topic.get("total_views"),
)
)
return parsed_threads