Daniel Brötzmann pushed to branch master at gajim / gajim


Commits:
e57e7b5c by wurstsalat at 2023-02-14T21:59:07+01:00
imprv: Improve get_recent_muc_nicks query

- - - - -


1 changed file:

- gajim/common/storage/archive.py


Changes:

=====================================
gajim/common/storage/archive.py
=====================================
@@ -848,25 +848,21 @@ def get_recent_muc_nicks(self, contact: GroupchatContact) 
-> list[str]:
         '''
         Queries the last 50 message rows and gathers nicknames in a list
         '''
-        jids = [contact.jid]
         account_id = self.get_account_id(contact.account)
-        kinds = map(str, [KindConstant.STATUS,
-                          KindConstant.GCSTATUS,
-                          KindConstant.ERROR])
 
         sql = '''
             SELECT contact_name
-            FROM logs NATURAL JOIN jids WHERE jid IN ({jids})
-            AND account_id = {account_id}
-            AND kind NOT IN ({kinds})
+            FROM logs NATURAL JOIN jids
+            WHERE +jid = ?
+            AND account_id = ?
+            AND kind = ?
             ORDER BY time DESC
-            '''.format(jids=', '.join('?' * len(jids)),
-                       account_id=account_id,
-                       kinds=', '.join(kinds))
+            '''
 
-        result = self._con.execute(
-            sql,
-            tuple(jids)).fetchmany(50)
+        result = self._con.execute(sql, (contact.jid,
+                                         account_id,
+                                         KindConstant.GC_MSG
+                                         )).fetchmany(50)
 
         nicknames: list[str] = []
         for row in result:



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

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


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to