mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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 <kevr@0cost.org>
This commit is contained in:
parent
d38abd7832
commit
01fb42c5d9
1 changed files with 9 additions and 9 deletions
|
@ -1,21 +1,21 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import time
|
from datetime import datetime
|
||||||
|
|
||||||
import aurweb.db
|
import aurweb.db
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
conn = aurweb.db.Connection()
|
conn = aurweb.db.Connection()
|
||||||
conn.execute("UPDATE PackageBases SET NumVotes = (" +
|
conn.execute(("UPDATE PackageBases SET NumVotes = ("
|
||||||
"SELECT COUNT(*) FROM PackageVotes " +
|
"SELECT COUNT(*) FROM PackageVotes "
|
||||||
"WHERE PackageVotes.PackageBaseID = PackageBases.ID)")
|
"WHERE PackageVotes.PackageBaseID = PackageBases.ID)"))
|
||||||
|
|
||||||
now = int(time.time())
|
now = int(datetime.utcnow().timestamp())
|
||||||
conn.execute("UPDATE PackageBases SET Popularity = (" +
|
conn.execute(("UPDATE PackageBases SET Popularity = ("
|
||||||
"SELECT COALESCE(SUM(POWER(0.98, (? - VoteTS) / 86400)), 0.0) " +
|
"SELECT COALESCE(SUM(POWER(0.98, (? - VoteTS) / 86400)), 0.0) "
|
||||||
"FROM PackageVotes WHERE PackageVotes.PackageBaseID = " +
|
"FROM PackageVotes WHERE PackageVotes.PackageBaseID = "
|
||||||
"PackageBases.ID AND NOT VoteTS IS NULL)", [now])
|
"PackageBases.ID AND NOT VoteTS IS NULL)"), [now])
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
Loading…
Add table
Reference in a new issue