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,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:**
-

View File

@@ -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

View File

@@ -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

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