diff options
author | wurstsalat <mailtrash@posteo.de> | 2023-02-20 00:34:17 +0300 |
---|---|---|
committer | wurstsalat <mailtrash@posteo.de> | 2023-02-20 00:34:17 +0300 |
commit | 508b0523d3497f60d5fef00d015deec8ad9f8dff (patch) | |
tree | b124bfe3df147a209eaa5774c2f0828fdcc33f31 | |
parent | a29845d75350a7fb5d3b4ca3acba2c4085b4dced (diff) |
cfix: Improve get_recent_muc_nicks query
-rw-r--r-- | gajim/common/storage/archive.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/gajim/common/storage/archive.py b/gajim/common/storage/archive.py index 48d506f52..4aef1358f 100644 --- a/gajim/common/storage/archive.py +++ b/gajim/common/storage/archive.py @@ -848,21 +848,22 @@ class MessageArchiveStorage(SqliteStorage): ''' 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.GC_MSG]) sql = ''' SELECT contact_name - FROM logs NATURAL JOIN jids - WHERE +jid = ? - AND account_id = ? - AND kind = ? + FROM logs NATURAL JOIN jids WHERE jid IN ({jids}) + AND account_id = {account_id} + AND kind IN ({kinds}) ORDER BY time DESC - ''' + '''.format(jids=', '.join('?' * len(jids)), + account_id=account_id, + kinds=', '.join(kinds)) + - result = self._con.execute(sql, (contact.jid, - account_id, - KindConstant.GC_MSG - )).fetchmany(50) + result = self._con.execute(sql, (tuple(jids))).fetchmany(50) nicknames: list[str] = [] for row in result: |