depcheck.py: move the filter into sql
authorHelmut Grohne <helmut@subdivi.de>
Sat, 2 Mar 2019 12:55:43 +0000 (13:55 +0100)
committerHelmut Grohne <helmut@subdivi.de>
Sat, 2 Mar 2019 12:55:43 +0000 (13:55 +0100)
depcheck.py

index 046b559..cb2e7e4 100755 (executable)
@@ -440,14 +440,17 @@ def main():
     args = argp.parse_args()
     mirror = DebianMirror(args.mirror)
     mirror.update_release()
-    db = sqlite3.connect("db", detect_types=sqlite3.PARSE_DECLTYPES)
+    db = sqlite3.connect("db")
     cur = db.cursor()
-    cur.execute("SELECT architecture, releasetime, updatetime, giveback FROM depcheck;")
     lastupdate = datetime.datetime.utcnow() - datetime.timedelta(hours=6)
-    for architecture, releasetime, updatetime, giveback in list(cur.fetchall()):
-        if giveback or updatetime < lastupdate or releasetime < mirror.releasetime:
-            print("update %s" % architecture)
-            update_depcheck(mirror, db, architecture)
+    cur.execute("""
+        SELECT architecture FROM depcheck
+            WHERE giveback = 1 OR updatetime < ? OR releasetime < ?;""",
+                (datetime.datetime.utcnow() - datetime.timedelta(hours=6),
+                 mirror.releasetime))
+    for architecture, in list(cur.fetchall()):
+        print("update %s" % architecture)
+        update_depcheck(mirror, db, architecture)
 
 if __name__ == "__main__":
     main()