From: Michael Tremer Date: Tue, 27 Sep 2022 07:59:37 +0000 (+0000) Subject: importer: Sync geofeeds X-Git-Tag: 0.9.17~29^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef8d1f676c62ba04edb919e09878521d410065d8;p=people%2Fms%2Flibloc.git importer: Sync geofeeds Geofeeds are kept in a separate table to only fetch them once per URL. This needs to be kept in sync which is done before we update any feeds. Signed-off-by: Michael Tremer --- diff --git a/src/scripts/location-importer.in b/src/scripts/location-importer.in index 014f3b6..12035f1 100644 --- a/src/scripts/location-importer.in +++ b/src/scripts/location-importer.in @@ -1279,6 +1279,38 @@ class CLI(object): yield line def handle_update_geofeeds(self, ns): + # Sync geofeeds + with self.db.transaction(): + # Delete all geofeeds which are no longer linked + self.db.execute(""" + DELETE FROM + geofeeds + WHERE + NOT EXISTS ( + SELECT + 1 + FROM + network_geofeeds + WHERE + geofeeds.url = network_geofeeds.url + )""", + ) + + # Copy all geofeeds + self.db.execute(""" + INSERT INTO + geofeeds( + url + ) + SELECT + url + FROM + network_geofeeds + ON CONFLICT (url) + DO NOTHING + """, + ) + # Fetch all Geofeeds that require an update geofeeds = self.db.query(""" SELECT