Philipp Hörist pushed to branch storage at gajim / gajim
Commits:
54f10954 by Philipp Hörist at 2024-04-09T18:22:18+02:00
fix: Add index on id
- - - - -
3843bf43 by Philipp Hörist at 2024-04-09T18:36:30+02:00
imprv: Improve debug output
- - - - -
3 changed files:
- gajim/common/storage/archive/models.py
- gajim/common/storage/archive/storage.py
- gajim/common/storage/cache.py
Changes:
=====================================
gajim/common/storage/archive/models.py
=====================================
@@ -665,6 +665,9 @@ class Message(MappedAsDataclass, Base, UtilMixin,
kw_only=True):
'fk_account_pk',
sa.text('timestamp ASC'),
),
+ Index(
+ 'idx_message_id', 'id', 'fk_remote_pk', 'fk_account_pk',
+ ),
Index(
'idx_stanza_id_unique',
'stanza_id',
=====================================
gajim/common/storage/archive/storage.py
=====================================
@@ -9,6 +9,7 @@
import calendar
import datetime as dt
import logging
+import pprint
import shutil
from collections.abc import Iterator
from collections.abc import Sequence
@@ -77,6 +78,11 @@ def init(self) -> None:
with self._session as s:
self._load_jids(s)
+ def _log_row(self, row: Any) -> None:
+ if self._log.getEffectiveLevel() != logging.DEBUG:
+ return
+ self._log.debug('Object before query\n%s', pprint.pformat(row))
+
def _create_table(self, session: Session, engine: Engine) -> None:
Base.metadata.create_all(engine)
session.execute(sa.text(f'PRAGMA user_version={CURRENT_USER_VERSION}'))
@@ -191,6 +197,7 @@ def insert_object(
self, session: Session, obj: Any, ignore_on_conflict: bool = True
) -> int:
self._set_foreign_keys(session, obj)
+ self._log_row(obj)
session.add(obj)
try:
@@ -229,7 +236,7 @@ def _insert_row(
ignore_on_conflict: bool = False,
) -> int:
self._set_foreign_keys(session, row)
-
+ self._log_row(row)
table = row.__class__
stmt =
insert(table).values(**row.get_insert_values()).returning(table.pk)
@@ -259,7 +266,7 @@ def _upsert_row(
row: Any,
) -> int:
self._set_foreign_keys(session, row)
-
+ self._log_row(row)
table = row.__class__
stmt = row.get_select_stmt()
=====================================
gajim/common/storage/cache.py
=====================================
@@ -338,7 +338,6 @@ def set_contact(self,
self._delayed_commit()
- @timeit
def get_contact(self, account: str, jid: JID, prop: str) -> Any:
try:
value, prop_ts = self._contact_cache[(account, jid)][prop]
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/a227d8119da8690a73692ecf367806a8ebdacac6...3843bf43abfe3578316515a434d7b15d5cf385c4
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/a227d8119da8690a73692ecf367806a8ebdacac6...3843bf43abfe3578316515a434d7b15d5cf385c4
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]