Fixed and tweaked getupdate

This commit is contained in:
Emily 2018-05-29 13:41:21 +02:00
parent fc3c0f44c5
commit e3188c7331

View File

@ -21,14 +21,15 @@ def handle(request):
def callback(method, data): def callback(method, data):
cur = glob.sql.cursor() cur = glob.sql.cursor()
if method is "file_hash": query = "SELECT a.* FROM updates a INNER JOIN ( SELECT MAX(file_version) file_version, filename FROM updates WHERE {} < {} GROUP BY filename) b ON a.file_version = b.file_version"
cur.execute("SELECT * FROM updates WHERE file_hash = '{}'".format( if method is "timestamp":
data query += " ORDER BY a.timestamp DESC"
)) elif method is "file_hash":
else: query = "SELECT * FROM updates WHERE {} = '{}'"
cur.execute("SELECT a.* FROM updates a INNER JOIN ( SELECT MAX(file_version) file_version, filename FROM updates WHERE {} < {} GROUP BY filename) b ON a.file_version = b.file_version;".format(
method, cur.execute("SELECT a.* FROM updates a INNER JOIN ( SELECT MAX(file_version) file_version, filename FROM updates WHERE {} < {} GROUP BY filename) b ON a.file_version = b.file_version;".format(
data method,
)) data
))
return cur.fetchall() return cur.fetchall()