Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
accef11c
Commit
accef11c
authored
7 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Logger: Get rid of old jids list
Use _jid_ids dict instead
parent
1c736922
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gajim/common/logger.py
+2
-19
2 additions, 19 deletions
gajim/common/logger.py
with
2 additions
and
19 deletions
gajim/common/logger.py
+
2
−
19
View file @
accef11c
...
...
@@ -107,7 +107,6 @@ class SubscriptionConstant(IntEnum):
class
Logger
:
def
__init__
(
self
):
self
.
jids_already_in
=
[]
# holds jids that we already have in DB
self
.
_jid_ids
=
{}
self
.
con
=
None
self
.
commit_timout_id
=
None
...
...
@@ -189,7 +188,6 @@ class Logger:
def
init_vars
(
self
):
self
.
open_db
()
self
.
get_jids_already_in_db
()
self
.
get_jid_ids_from_db
()
@staticmethod
...
...
@@ -237,22 +235,8 @@ class Logger:
for
row
in
rows
:
self
.
_jid_ids
[
row
.
jid
]
=
row
def
get_jids_already_in_db
(
self
):
try
:
self
.
cur
.
execute
(
'
SELECT jid FROM jids
'
)
rows
=
self
.
cur
.
fetchall
()
except
sqlite
.
DatabaseError
:
raise
exceptions
.
DatabaseMalformed
(
LOG_DB_PATH
)
self
.
jids_already_in
=
[]
for
row
in
rows
:
if
not
row
.
jid
:
# malformed jid, ignore line
pass
else
:
self
.
jids_already_in
.
append
(
row
.
jid
)
def
get_jids_in_db
(
self
):
return
self
.
jid
s_already_in
return
self
.
_
jid
_ids
.
keys
()
def
jid_is_from_pm
(
self
,
jid
):
"""
...
...
@@ -1102,13 +1086,12 @@ class Logger:
:param type_: A JIDConstant
"""
if
jid
in
self
.
jid
s_already_in
:
if
jid
in
self
.
_
jid
_ids
:
return
if
kind
in
(
KindConstant
.
GC_MSG
,
KindConstant
.
GCSTATUS
):
type_
=
JIDConstant
.
ROOM_TYPE
sql
=
'
INSERT OR IGNORE INTO jids (jid, type) VALUES (?, ?)
'
self
.
con
.
execute
(
sql
,
(
jid
,
type_
))
self
.
jids_already_in
.
append
(
jid
)
self
.
_timeout_commit
()
def
insert_into_logs
(
self
,
jid
,
time_
,
kind
,
unread
=
True
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment