mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Instead of using configparser and mysql.connector directly, change all Python scripts to use the config and db Python modules which are now accessible from a common location. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
23 lines
642 B
Python
Executable file
23 lines
642 B
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import aurweb.db
|
|
|
|
|
|
def main():
|
|
conn = aurweb.db.Connection()
|
|
|
|
conn.execute("UPDATE PackageBases SET NumVotes = (" +
|
|
"SELECT COUNT(*) FROM PackageVotes " +
|
|
"WHERE PackageVotes.PackageBaseID = PackageBases.ID)")
|
|
|
|
conn.execute("UPDATE PackageBases SET Popularity = (" +
|
|
"SELECT COALESCE(SUM(POWER(0.98, (UNIX_TIMESTAMP() - VoteTS) / 86400)), 0.0) " +
|
|
"FROM PackageVotes WHERE PackageVotes.PackageBaseID = " +
|
|
"PackageBases.ID AND NOT VoteTS IS NULL)")
|
|
|
|
conn.commit()
|
|
conn.close()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|