summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2015-06-11 18:41:58 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-06-11 18:59:52 +0200
commit824744f1d20614c25e972dda7a0b7ac9506dd46f (patch)
tree5f9b58f6264553184779d54569e72b2fbf0cbdb1 /scripts
parent0345914c5ce5e8ecafe3e90280bd58c0255fd9e0 (diff)
downloadaurweb-824744f1d20614c25e972dda7a0b7ac9506dd46f.tar.xz
Add a field for package base popularity
Create a new field Popularity in the PackageBases table. The field is updated by the popupdate script and reflects the popularity of a package. Popularity is the sum of all votes with each vote being weighted with a factor of 0.98 per day since its creation. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/popupdate.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/scripts/popupdate.py b/scripts/popupdate.py
index 489cd41..f4c99ca 100755
--- a/scripts/popupdate.py
+++ b/scripts/popupdate.py
@@ -23,5 +23,10 @@ cur = db.cursor()
cur.execute("UPDATE PackageBases SET NumVotes = (SELECT COUNT(*) FROM " +
"PackageVotes WHERE PackageVotes.PackageBaseID = PackageBases.ID)")
+cur.execute("UPDATE PackageBases SET Popularity = (" +
+ "SELECT SUM(POWER(0.98, (UNIX_TIMESTAMP() - VoteTS) / 86400)) " +
+ "FROM PackageVotes WHERE PackageVotes.PackageBaseID = " +
+ "PackageBases.ID AND NOT VoteTS IS NULL)")
+
db.commit()
db.close()