Fix parameter processing in parse_multiinfo_args()
[aur.git] / scripts / popupdate.py
blob2aa8a54619c86bfb7e7c8b1f8307420c27eb8368
1 #!/usr/bin/python3
3 import configparser
4 import mysql.connector
5 import os
7 config = configparser.RawConfigParser()
8 config.read(os.path.dirname(os.path.realpath(__file__)) + "/../conf/config")
10 aur_db_host = config.get('database', 'host')
11 aur_db_name = config.get('database', 'name')
12 aur_db_user = config.get('database', 'user')
13 aur_db_pass = config.get('database', 'password')
14 aur_db_socket = config.get('database', 'socket')
16 db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
17 passwd=aur_db_pass, db=aur_db_name,
18 unix_socket=aur_db_socket, buffered=True)
19 cur = db.cursor()
21 cur.execute("UPDATE PackageBases SET NumVotes = (SELECT COUNT(*) FROM " +
22 "PackageVotes WHERE PackageVotes.PackageBaseID = PackageBases.ID)")
24 cur.execute("UPDATE PackageBases SET Popularity = (" +
25 "SELECT SUM(POWER(0.98, (UNIX_TIMESTAMP() - VoteTS) / 86400)) " +
26 "FROM PackageVotes WHERE PackageVotes.PackageBaseID = " +
27 "PackageBases.ID AND NOT VoteTS IS NULL)")
29 db.commit()
30 db.close()