]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
geofeeds: Delete any data that did not update within two weeks
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 4 Jul 2023 10:01:51 +0000 (10:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 4 Jul 2023 10:01:51 +0000 (10:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/location-importer.in

index 310e4eea125d76ee77a2d8bc4c3d9b12a6b52db5..20527f60b8908f1c28ac49c74041fea5cfd473ad 100644 (file)
@@ -1299,6 +1299,24 @@ class CLI(object):
                        for result in results:
                                pass
 
+               # Delete data from any feeds that did not update in the last two weeks
+               with self.db.transaction():
+                       self.db.execute("""
+                               DELETE FROM
+                                       geofeed_networks
+                               WHERE
+                                       geofeed_networks.geofeed_id IN (
+                                               SELECT
+                                                       geofeeds.id
+                                               FROM
+                                                       geofeeds
+                                               WHERE
+                                                       updated_at IS NULL
+                                               OR
+                                                       updated_at <= CURRENT_TIMESTAMP - INTERVAL '2 weeks'
+                                       )
+                       """)
+
        def _fetch_geofeed(self, geofeed):
                log.debug("Fetching Geofeed %s" % geofeed.url)