summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/pkgmaint.py6
-rwxr-xr-xscripts/popupdate.py7
2 files changed, 9 insertions, 4 deletions
diff --git a/scripts/pkgmaint.py b/scripts/pkgmaint.py
index d0f8fe70..3ad9ed8d 100755
--- a/scripts/pkgmaint.py
+++ b/scripts/pkgmaint.py
@@ -1,14 +1,16 @@
#!/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()
diff --git a/scripts/popupdate.py b/scripts/popupdate.py
index f5e09d97..58cd0185 100755
--- a/scripts/popupdate.py
+++ b/scripts/popupdate.py
@@ -1,5 +1,7 @@
#!/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()