From e2d1f2b9efab8ccbce77a5eb2dc211764c775b23 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 8 Oct 2020 14:17:19 -0700 Subject: [PATCH] Some small whitespace and log tweaks. --- timesearch_modules/get_comments.py | 5 ++--- timesearch_modules/pushshift.py | 1 + timesearch_modules/tsdb.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/timesearch_modules/get_comments.py b/timesearch_modules/get_comments.py index 5c70ed9..592ab89 100644 --- a/timesearch_modules/get_comments.py +++ b/timesearch_modules/get_comments.py @@ -5,7 +5,6 @@ from . import exceptions from . import pushshift from . import tsdb - def get_comments( subreddit=None, username=None, @@ -74,12 +73,11 @@ def get_comments( elif username: comments = pushshift.get_comments_from_user(username, lower=lower, upper=upper) - if do_supplement: comments = pushshift.supplement_reddit_data(comments, chunk_size=100) + comments = common.generator_chunker(comments, 500) form = '{lower} ({lower_unix}) - {upper} ({upper_unix}) +{gain}' - comments = common.generator_chunker(comments, 500) for chunk in comments: step = database.insert(chunk) message = form.format( @@ -90,6 +88,7 @@ def get_comments( gain=step['new_comments'], ) print(message) + if specific_submission: query = ''' UPDATE submissions diff --git a/timesearch_modules/pushshift.py b/timesearch_modules/pushshift.py index c7fc2fb..e2d36f4 100644 --- a/timesearch_modules/pushshift.py +++ b/timesearch_modules/pushshift.py @@ -238,6 +238,7 @@ def supplement_reddit_data(dummies, chunk_size=100): ''' chunks = common.generator_chunker(dummies, chunk_size) for chunk in chunks: + common.log.debug('Supplementing %d items with live reddit data.', len(chunk)) ids = [item.fullname for item in chunk] live_copies = list(common.r.info(ids)) live_copies = {item.fullname: item for item in live_copies} diff --git a/timesearch_modules/tsdb.py b/timesearch_modules/tsdb.py index 44a79a4..29ce091 100644 --- a/timesearch_modules/tsdb.py +++ b/timesearch_modules/tsdb.py @@ -346,7 +346,7 @@ class TSDB: new_values[key] += status if commit: - common.log.debug('Committing insert') + common.log.debug('Committing insert.') self.sql.commit() common.log.debug('Done inserting.')