diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2016-10-17 15:20:29 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2016-10-17 15:23:13 +0200 |
commit | 37188603b52a3dac23df229ada82c7da0c3d9c00 (patch) | |
tree | f7df7af7edcd8ca49fe1354883537013d020319f /aurweb/scripts/popupdate.py | |
parent | 85866796a40923708f6b868c32ddc2f2f4417d1d (diff) | |
download | aur-37188603b52a3dac23df229ada82c7da0c3d9c00.tar.gz aur-37188603b52a3dac23df229ada82c7da0c3d9c00.tar.xz |
Make maintenance scripts installable
Add wrappers for the maintenance scripts to the setuptools
configuration.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'aurweb/scripts/popupdate.py')
-rwxr-xr-x | aurweb/scripts/popupdate.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/aurweb/scripts/popupdate.py b/aurweb/scripts/popupdate.py new file mode 100755 index 00000000..58cd0185 --- /dev/null +++ b/aurweb/scripts/popupdate.py @@ -0,0 +1,26 @@ +#!/usr/bin/python3 + +import time + +import aurweb.db + + +def main(): + conn = aurweb.db.Connection() + + conn.execute("UPDATE PackageBases SET NumVotes = (" + + "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, (? - VoteTS) / 86400)), 0.0) " + + "FROM PackageVotes WHERE PackageVotes.PackageBaseID = " + + "PackageBases.ID AND NOT VoteTS IS NULL)", [now]) + + conn.commit() + conn.close() + + +if __name__ == '__main__': + main() |