From: Michael Tremer Date: Fri, 12 Jan 2024 15:55:24 +0000 (+0000) Subject: fireinfo: Store empty profiles as NULL instead of serialised JSON X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15733ec8f1393dea3aba48d63798b950e6ad194b;p=ipfire.org.git fireinfo: Store empty profiles as NULL instead of serialised JSON This will allow us to filter out deleted profiles with a simple "blob IS NULL". Signed-off-by: Michael Tremer --- diff --git a/src/backend/fireinfo.py b/src/backend/fireinfo.py index 0cc5e268..1f459b8f 100644 --- a/src/backend/fireinfo.py +++ b/src/backend/fireinfo.py @@ -855,6 +855,10 @@ class Fireinfo(Object): self.db.execute("UPDATE fireinfo SET expired_at = CURRENT_TIMESTAMP \ WHERE profile_id = %s AND expired_at IS NULL", profile_id) + # Serialise the profile + if profile: + profile = json.dumps(profile) + # Store the new profile self.db.execute(""" INSERT INTO @@ -876,7 +880,7 @@ class Fireinfo(Object): %s, %s ) - """, profile_id, private_id, version, json.dumps(profile), country_code, asn, + """, profile_id, private_id, version, profile, country_code, asn, ) def _validate(self, profile_id, version, blob):