Use the same print format for get_submissions and get_comments.

master
Ethan Dalool 2020-10-08 13:15:05 -07:00
parent b412b5fd98
commit 3869e5a99a
2 changed files with 6 additions and 4 deletions

View File

@ -74,11 +74,11 @@ def get_comments(
elif username: elif username:
comments = pushshift.get_comments_from_user(username, lower=lower, upper=upper) comments = pushshift.get_comments_from_user(username, lower=lower, upper=upper)
form = '{lower} ({lower_unix}) - {upper} ({upper_unix}) +{gain}'
if do_supplement: if do_supplement:
comments = pushshift.supplement_reddit_data(comments, chunk_size=100) comments = pushshift.supplement_reddit_data(comments, chunk_size=100)
form = '{lower} ({lower_unix}) - {upper} ({upper_unix}) +{gain}'
comments = common.generator_chunker(comments, 500) comments = common.generator_chunker(comments, 500)
for chunk in comments: for chunk in comments:
step = database.insert(chunk) step = database.insert(chunk)

View File

@ -69,14 +69,16 @@ def get_submissions(
submissions = pushshift.supplement_reddit_data(submissions, chunk_size=100) submissions = pushshift.supplement_reddit_data(submissions, chunk_size=100)
submissions = common.generator_chunker(submissions, 200) submissions = common.generator_chunker(submissions, 200)
form = '{lower} - {upper} +{gain}' form = '{lower} ({lower_unix}) - {upper} ({upper_unix}) +{gain}'
for chunk in submissions: for chunk in submissions:
chunk.sort(key=lambda x: x.created_utc) chunk.sort(key=lambda x: x.created_utc)
new_count = database.insert(chunk)['new_submissions'] step = database.insert(chunk)
message = form.format( message = form.format(
lower=common.human(chunk[0].created_utc), lower=common.human(chunk[0].created_utc),
upper=common.human(chunk[-1].created_utc), upper=common.human(chunk[-1].created_utc),
gain=new_count, lower_unix=int(chunk[0].created_utc),
upper_unix=int(chunk[-1].created_utc),
gain=step['new_submissions'],
) )
print(message) print(message)