Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
izdwuut committed Feb 23, 2020
2 parents f16a276 + a7ea1cf commit 17316bf
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions backend/app/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Errors:
REDDIT_KARMA_TOO_LOW = 'Karma too low.'
BAD_URL = 'Bad URL!'
NO_REQUIRED_KEYWORDS = 'No required keywords: '
REDDIT_SERVER_ERROR = "Couldn't scrap comment due to Reddit server error."

# General
BLACKLISTED = 'Blacklisted.'
Expand Down
28 changes: 20 additions & 8 deletions backend/app/cache/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import logging
import requests
from flask_cors import cross_origin
from prawcore.exceptions import ServerError
from time import sleep

cache = Blueprint('cache', __name__, url_prefix='/cache')

Expand Down Expand Up @@ -252,16 +254,26 @@ def run_thread(self, thread):
return self.get_json(self.get_comments_from_db(submission.url)), 200

def run_stream(self):
for comment in self.reddit.get_regular_comment():
if self.scrap_comment(comment):
self.filter_comment(comment)
logging.info('Scrapped comment: {}.'.format(comment.id))
while True:
try:
for comment in self.reddit.get_regular_comment():
if self.scrap_comment(comment):
self.filter_comment(comment)
logging.info('Scrapped comment: {}.'.format(comment.id))
except ServerError:
logging.error(Errors.REDDIT_SERVER_ERROR)
sleep(30)

def run_edited_stream(self):
for comment in self.reddit.get_edited_comment():
if self.scrap_comment(comment):
self.filter_comment(comment)
logging.info('Scrapped edited comment: {}.'.format(comment.id))
while True:
try:
for comment in self.reddit.get_edited_comment():
if self.scrap_comment(comment):
self.filter_comment(comment)
logging.info('Scrapped edited comment: {}.'.format(comment.id))
except ServerError:
logging.error(Errors.REDDIT_SERVER_ERROR)
sleep(30)

def __init__(self):
self.steam = Steam(current_app.config['STEAM'])
Expand Down
2 changes: 1 addition & 1 deletion backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RedditConfig:
CLIENT_SECRET = os.environ['GOG_PICKER_REDDIT_CLIENT_SECRET']
USERNAME = os.environ['GOG_PICKER_REDDIT_USERNAME']
PASSWORD = os.environ['GOG_PICKER_REDDIT_PASSWORD']
USER_AGENT = 'python:gog-picker:v0.15.0g (by /u/izdwuut)'
USER_AGENT = 'python:gog-picker:v0.15.1 (by /u/izdwuut)'
NOT_ENTERING = 'not entering'
MIN_KARMA = 300

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/thread/thread.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ <h1>Scrapped comments</h1>
No comments detected!
</div>
<div *ngIf='isHttpError' class="no-results">
Something went wrong. <a [routerLink]="['/']">Please try again.</a>
Something went wrong. <a [routerLink]="['/']" >Please try again.</a>
</div>
<div class="results" >
<div class="results" *ngIf="!isHttpError">
<div *ngFor="let comment of comments">
<mat-card class="comment warning" *ngIf="hasWarnings(comment) && comment.entering">
<mat-card-title>
Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/thread/thread.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
}

.actions {
margin: 1% 0;
grid-area: actions;
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<body>
<app-root></app-root>
<footer class="footer">
Gift of Games Picker for Reddit <a href="https://github.com/izdwuut/gog-picker">v0.15.0</a>.
Gift of Games Picker for Reddit <a href="https://github.com/izdwuut/gog-picker">v0.15.1</a>.
Scripted by <a href="https://reddit.com/u/izdwuut">u/izdwuut</a> and <a href="https://github.com/izdwuut/gog-picker/pulls">friends</a> in open source.
Licensed under <a href="https://github.com/izdwuut/gog-picker/blob/dev/LICENSE">MIT Licence</a>
</footer>
Expand Down

0 comments on commit 17316bf

Please sign in to comment.