mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
scripts: Do not use UNIX_TIMESTAMP
Avoid using UNIX_TIMESTAMP which is not part of the SQL standard.
See f2a6bd2
(git-interface: Do not use UNIX_TIMESTAMP, 2016-08-05) for
related changes.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
cd2d90612b
commit
91f649f5ed
2 changed files with 9 additions and 4 deletions
|
@ -1,14 +1,16 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
import aurweb.db
|
import aurweb.db
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
conn = aurweb.db.Connection()
|
conn = aurweb.db.Connection()
|
||||||
|
|
||||||
|
limit_to = int(time.time()) - 86400
|
||||||
conn.execute("DELETE FROM PackageBases WHERE " +
|
conn.execute("DELETE FROM PackageBases WHERE " +
|
||||||
"UNIX_TIMESTAMP() - SubmittedTS > 86400 " +
|
"SubmittedTS < ? AND PackagerUID IS NULL", [limit_to])
|
||||||
"AND PackagerUID IS NULL")
|
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
import aurweb.db
|
import aurweb.db
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,10 +12,11 @@ def main():
|
||||||
"SELECT COUNT(*) FROM PackageVotes " +
|
"SELECT COUNT(*) FROM PackageVotes " +
|
||||||
"WHERE PackageVotes.PackageBaseID = PackageBases.ID)")
|
"WHERE PackageVotes.PackageBaseID = PackageBases.ID)")
|
||||||
|
|
||||||
|
now = int(time.time())
|
||||||
conn.execute("UPDATE PackageBases SET Popularity = (" +
|
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 = " +
|
"FROM PackageVotes WHERE PackageVotes.PackageBaseID = " +
|
||||||
"PackageBases.ID AND NOT VoteTS IS NULL)")
|
"PackageBases.ID AND NOT VoteTS IS NULL)", [now])
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
Loading…
Add table
Reference in a new issue