From 2e507c1bfb41bd8d8c8c27dfe0060399ad4348fd Mon Sep 17 00:00:00 2001 From: Dave Gallant Date: Tue, 17 Dec 2019 23:04:27 -0500 Subject: [PATCH] Add view count to each thread (#53) --- .github/PULL_REQUEST_TEMPLATE.md | 11 ++++++----- README.md | 14 +++++++------- requirements.txt | 6 +++--- rfd/VERSION | 2 +- rfd/cli.py | 3 +++ rfd/models.py | 3 ++- rfd/parsing.py | 1 + 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 2d46221..26094de 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,9 @@ -*Description of changes:* +**What this PR does / why we need it:** +- -*Checklist:* +**Which issue(s) this PR fixes:** +- -- [ ] Write unit tests -- [ ] `make pr` passes -- [ ] Write documentation +**Additional Notes:** +- diff --git a/README.md b/README.md index 8e1aea5..ebdb835 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,18 @@ Hot deals on the command line. [![Total alerts](https://img.shields.io/lgtm/alerts/g/davegallant/rfd.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/davegallant/rfd/alerts/) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/davegallant/rfd.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/davegallant/rfd/context:python) -## Installation + +![image](https://user-images.githubusercontent.com/4519234/71054408-e18c6a00-211f-11ea-89bc-3f990a4909de.png) + +## Install ```bash pip install rfd ``` -## Usage +## Use -![rfd_demo_gif](https://user-images.githubusercontent.com/4519234/64501455-64836600-d28f-11e9-8381-3fbfda910230.gif) - - -### threads +### view threads ```bash rfd threads [--forum-id 9] [--limit 10] ``` @@ -29,7 +29,7 @@ rfd threads [--forum-id 9] [--limit 10] rfd search pizza [--num-pages 100] ``` -## Tab Completion +## Support Tab Completion ### bash diff --git a/requirements.txt b/requirements.txt index dba710f..62bda28 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -beautifulsoup4>=4.6.0 +beautifulsoup4>=4.8.1 click>=7.0 -colorama>=0.3.9 -requests>=2.18.0 +colorama>=0.4.3 +requests>=2.22.0 diff --git a/rfd/VERSION b/rfd/VERSION index 1c09c74..42045ac 100644 --- a/rfd/VERSION +++ b/rfd/VERSION @@ -1 +1 @@ -0.3.3 +0.3.4 diff --git a/rfd/cli.py b/rfd/cli.py index 7ee2a51..3c1f5f3 100644 --- a/rfd/cli.py +++ b/rfd/cli.py @@ -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) diff --git a/rfd/models.py b/rfd/models.py index b362b3e..5d68a66 100644 --- a/rfd/models.py +++ b/rfd/models.py @@ -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 diff --git a/rfd/parsing.py b/rfd/parsing.py index f50a27b..d80afa5 100644 --- a/rfd/parsing.py +++ b/rfd/parsing.py @@ -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