Commit 91f649f5 authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

scripts: Do not use UNIX_TIMESTAMP

Avoid using UNIX_TIMESTAMP which is not part of the SQL standard.

See f2a6bd20

 (git-interface: Do not use UNIX_TIMESTAMP, 2016-08-05) for
related changes.
Signed-off-by: Lukas Fleischer's avatarLukas Fleischer <lfleischer@archlinux.org>
parent cd2d9061
#!/usr/bin/python3
import time
import aurweb.db
def main():
conn = aurweb.db.Connection()
limit_to = int(time.time()) - 86400
conn.execute("DELETE FROM PackageBases WHERE " +
"UNIX_TIMESTAMP() - SubmittedTS > 86400 " +
"AND PackagerUID IS NULL")
"SubmittedTS < ? AND PackagerUID IS NULL", [limit_to])
conn.commit()
conn.close()
......
#!/usr/bin/python3
import time
import aurweb.db
......@@ -10,10 +12,11 @@ def main():
"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, (UNIX_TIMESTAMP() - VoteTS) / 86400)), 0.0) " +
"SELECT COALESCE(SUM(POWER(0.98, (? - VoteTS) / 86400)), 0.0) " +
"FROM PackageVotes WHERE PackageVotes.PackageBaseID = " +
"PackageBases.ID AND NOT VoteTS IS NULL)")
"PackageBases.ID AND NOT VoteTS IS NULL)", [now])
conn.commit()
conn.close()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment