From 01fb42c5d97fe930b63ef8b71d4b2a2b62f32a5e Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Thu, 7 Oct 2021 22:44:54 -0700 Subject: [PATCH] fix(scripts.popupdate): use forced-utc timestamp Additionally, clean up some controversial PEP-8 warnings by removing the '+' string concatenation. Signed-off-by: Kevin Morris --- aurweb/scripts/popupdate.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/aurweb/scripts/popupdate.py b/aurweb/scripts/popupdate.py index b1e70403..96155eef 100755 --- a/aurweb/scripts/popupdate.py +++ b/aurweb/scripts/popupdate.py @@ -1,21 +1,21 @@ #!/usr/bin/env python3 -import time +from datetime import datetime import aurweb.db def main(): conn = aurweb.db.Connection() - conn.execute("UPDATE PackageBases SET NumVotes = (" + - "SELECT COUNT(*) FROM PackageVotes " + - "WHERE PackageVotes.PackageBaseID = PackageBases.ID)") + conn.execute(("UPDATE PackageBases SET NumVotes = (" + "SELECT COUNT(*) FROM PackageVotes " + "WHERE PackageVotes.PackageBaseID = PackageBases.ID)")) - now = int(time.time()) - conn.execute("UPDATE PackageBases SET Popularity = (" + - "SELECT COALESCE(SUM(POWER(0.98, (? - VoteTS) / 86400)), 0.0) " + - "FROM PackageVotes WHERE PackageVotes.PackageBaseID = " + - "PackageBases.ID AND NOT VoteTS IS NULL)", [now]) + now = int(datetime.utcnow().timestamp()) + conn.execute(("UPDATE PackageBases SET Popularity = (" + "SELECT COALESCE(SUM(POWER(0.98, (? - VoteTS) / 86400)), 0.0) " + "FROM PackageVotes WHERE PackageVotes.PackageBaseID = " + "PackageBases.ID AND NOT VoteTS IS NULL)"), [now]) conn.commit() conn.close()