Philipp Hörist pushed to branch storage at gajim / gajim


Commits:
e1f4db36 by Philipp Hörist at 2023-07-09T17:15:43+02:00
Simplify deletes

- - - - -


2 changed files:

- gajim/common/storage/archive/storage.py
- test/database/test_foreign_keys.py


Changes:

=====================================
gajim/common/storage/archive/storage.py
=====================================
@@ -862,24 +862,9 @@ def remove_history(self, account: str, jid: JID) -> None:
 
         account_ek = self._get_account_ek(account)
         jid_ek = self._get_jid_ek(jid)
-        # TODO
-        # try:
-        #     jid_id = self.get_jid_id(jid)
-        # except ValueError:
-        #     log.info('No history entries for: %s', jid)
-        #     return
-
-        find_stmt = '''
-            SELECT entitykey FROM message
-            WHERE fk_account_ek = ? and fk_jid_ek = ?
-        '''
-
-        params = (account_ek, jid_ek)
-
-        self._delete_messages(find_stmt, params)
-        self._commit()
 
         statements = [
+            'DELETE FROM message WHERE fk_account_ek = ? and fk_jid_ek = ?',
             'DELETE FROM error WHERE fk_account_ek = ? and fk_jid_ek = ?',
             'DELETE FROM reaction WHERE fk_account_ek = ? and fk_jid_ek = ?',
             'DELETE FROM retraction WHERE fk_account_ek = ? and fk_jid_ek = ?',
@@ -889,7 +874,9 @@ def remove_history(self, account: str, jid: JID) -> None:
         ]
 
         for stmt in statements:
-            self._con.execute(stmt, params)
+            self._con.execute(stmt, (account_ek, jid_ek))
+
+        self._commit()
 
         log.info('Removed history for: %s', jid)
 
@@ -898,10 +885,6 @@ def remove_all_history(self) -> None:
         Remove all messages for all accounts
         '''
         statements = [
-            'DELETE FROM call',
-            'DELETE FROM filetransfer',
-            'DELETE FROM oob',
-            'DELETE FROM reply',
             'DELETE FROM error',
             'DELETE FROM reaction',
             'DELETE FROM retraction',


=====================================
test/database/test_foreign_keys.py
=====================================
@@ -25,7 +25,7 @@ def setUp(self) -> None:
         self._remote_jid = JID.from_string('[email protected]')
         self._occupant_id = 'occupantid1'
 
-    def test_message_delete_cascade(self):
+    def test_message_delete_cascade(self) -> None:
         oob_data = DbInsertOOBRowData(
             url='https://www.test.com',
             description='somedesc'



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/e1f4db367bc991a755a06ef4bfc3ab9b407daa5b

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/e1f4db367bc991a755a06ef4bfc3ab9b407daa5b
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to