fix #1
This commit is contained in:
pare
c4a9b27912
commit
cba9a3b650
S'han modificat 2 arxius amb 13 adicions i 13 eliminacions
|
@ -33,13 +33,13 @@ class Database():
|
||||||
self.__create_config(self)
|
self.__create_config(self)
|
||||||
self.__write_config(self)
|
self.__write_config(self)
|
||||||
|
|
||||||
def find_follower(self, follower, account):
|
def find_follower(self, account):
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
|
|
||||||
select_sql = "select from followers where follower=(%s) and account=(%s)"
|
select_sql = "select from followers where account=(%s)"
|
||||||
|
|
||||||
conn = None
|
conn = None
|
||||||
|
|
||||||
|
@ -49,23 +49,23 @@ class Database():
|
||||||
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
|
||||||
print(f'Searching follower {follower}...')
|
print(f'Searching follower {account}...')
|
||||||
|
|
||||||
cur.execute(select_sql, (follower, account))
|
cur.execute(select_sql, (account,))
|
||||||
|
|
||||||
row = cur.fetchone()
|
row = cur.fetchone()
|
||||||
|
|
||||||
if row != None:
|
if row != None:
|
||||||
|
|
||||||
print(f'follower {follower} is already in the database.')
|
print(f'follower {account} is already in the database.')
|
||||||
|
|
||||||
found = True
|
found = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
print(f'follower {follower} not found! Adding it...')
|
print(f'follower {account} not found! Adding it...')
|
||||||
|
|
||||||
self.save_follower(follower, account)
|
self.save_follower(account)
|
||||||
|
|
||||||
cur.close()
|
cur.close()
|
||||||
|
|
||||||
|
@ -79,11 +79,11 @@ class Database():
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
def save_follower(self, follower, account):
|
def save_follower(self, account):
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
|
||||||
insert_sql = "INSERT INTO followers(follower, account, updated_at) VALUES(%s,%s,%s) ON CONFLICT DO NOTHING"
|
insert_sql = "INSERT INTO followers(account, updated_at) VALUES(%s,%s) ON CONFLICT DO NOTHING"
|
||||||
|
|
||||||
conn = None
|
conn = None
|
||||||
|
|
||||||
|
@ -93,9 +93,9 @@ class Database():
|
||||||
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
|
||||||
print(f'Writing follower {follower}...')
|
print(f'Writing follower {account}...')
|
||||||
|
|
||||||
cur.execute(insert_sql, (follower, account, now))
|
cur.execute(insert_sql, (account, now))
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ class Database():
|
||||||
|
|
||||||
db = self.followers_db
|
db = self.followers_db
|
||||||
table = "followers"
|
table = "followers"
|
||||||
sql = "create table "+table+" (follower varchar(50) PRIMARY KEY, account varchar(100), updated_at timestamptz)"
|
sql = "create table "+table+" (account varchar(100) PRIMARY KEY, updated_at timestamptz)"
|
||||||
self.__create_table(self, table, sql)
|
self.__create_table(self, table, sql)
|
||||||
|
|
||||||
table = "total"
|
table = "total"
|
||||||
|
|
|
@ -58,7 +58,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
for follower in followers:
|
for follower in followers:
|
||||||
|
|
||||||
db.find_follower(follower.username, follower.acct)
|
db.find_follower(follower.acct)
|
||||||
|
|
||||||
last_local, last_remote = db.last_total()
|
last_local, last_remote = db.last_total()
|
||||||
|
|
||||||
|
|
Loading…
Referencia en una nova incidència