]> git.ipfire.org Git - ipfire.org.git/commitdiff
fireinfo: Store empty profiles as NULL instead of serialised JSON
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 Jan 2024 15:55:24 +0000 (15:55 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 Jan 2024 15:55:24 +0000 (15:55 +0000)
This will allow us to filter out deleted profiles with a simple "blob IS
NULL".

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/fireinfo.py

index 0cc5e268e8c8f6f8a88c1af1e05dd3aad4adb4ad..1f459b8f50231aa2762b462d15821c7f0790f116 100644 (file)
@@ -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):