summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2016-03-01 08:45:46 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2016-03-01 18:27:23 +0100
commit4c15f02ecb01e5d31ee575ead72c5b33db731032 (patch)
tree2b0b2457a09271a18207e7d772fb1357733faf25 /scripts
parentc23914fc1df309a6b1d85ec5387cfbef2161e655 (diff)
downloadaur-4c15f02ecb01e5d31ee575ead72c5b33db731032.tar.gz
aur-4c15f02ecb01e5d31ee575ead72c5b33db731032.tar.xz
popupdate: Avoid NULL entries in the popularity field
The popularity field is declared as "NOT NULL" in the database schema. Fix the popularity update query such that it uses a popularity of 0.0 instead of NULL for packages with no votes. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/popupdate.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/popupdate.py b/scripts/popupdate.py
index 2aa8a546..f3ba5131 100755
--- a/scripts/popupdate.py
+++ b/scripts/popupdate.py
@@ -22,7 +22,7 @@ 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)) " +
+ "SELECT COALESCE(SUM(POWER(0.98, (UNIX_TIMESTAMP() - VoteTS) / 86400)), 0.0) " +
"FROM PackageVotes WHERE PackageVotes.PackageBaseID = " +
"PackageBases.ID AND NOT VoteTS IS NULL)")