Fill dates without spam attempts with zeros

This commit is contained in:
spla 2022-01-19 14:12:25 +01:00
pare e929ea2526
commit e6bbafefc7

Veure arxiu

@ -1,4 +1,4 @@
import datetime
from datetime import datetime, timedelta
from mastodon import Mastodon
import time
import os
@ -15,6 +15,8 @@ def write_totals(spamcheck_datetime_lst, spamcheck_registers_lst):
insert_sql = 'INSERT INTO totals(datetime, registers) VALUES(%s,%s) ON CONFLICT (datetime) DO UPDATE SET (datetime, registers) = (EXCLUDED.datetime, EXCLUDED.registers)'
first_date = spamcheck_datetime_lst[0]
i = 0
while i < len(spamcheck_datetime_lst):
@ -27,8 +29,16 @@ def write_totals(spamcheck_datetime_lst, spamcheck_registers_lst):
cur = conn.cursor()
if first_date == spamcheck_datetime_lst[i]:
cur.execute(insert_sql, (spamcheck_datetime_lst[i], spamcheck_registers_lst[i]))
i += 1
else:
cur.execute(insert_sql, (first_date, '0'))
conn.commit()
cur.close()
@ -43,7 +53,7 @@ def write_totals(spamcheck_datetime_lst, spamcheck_registers_lst):
conn.close()
i += 1
first_date = first_date + timedelta(days=1)
def get_totals():