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
norstbox
gajim
Commits
ebccabf5
Commit
ebccabf5
authored
19 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
[Jim] faster version of do_possible_mark_for_days_in_this_month()
parent
ff98aab6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/logger.py
+38
-15
38 additions, 15 deletions
src/common/logger.py
src/history_window.py
+6
-7
6 additions, 7 deletions
src/history_window.py
with
44 additions
and
22 deletions
src/common/logger.py
+
38
−
15
View file @
ebccabf5
...
...
@@ -343,30 +343,53 @@ class Logger:
results
=
self
.
cur
.
fetchall
()
return
results
def
date_has_logs
(
self
,
jid
,
year
,
month
,
day
):
'''
returns True if we have logs (excluding statuses) for given date,
else False
'''
def
get_days_with_logs
(
self
,
jid
,
year
,
month
,
max_day
):
'''
returns the list of days that have logs (not status messages)
'''
jid
=
jid
.
lower
()
jid_id
=
self
.
get_jid_id
(
jid
)
start_of_day
=
self
.
get_unix_time_from_date
(
year
,
month
,
day
)
list
=
[]
# First select all date of month whith logs we want
start_of_month
=
self
.
get_unix_time_from_date
(
year
,
month
,
1
)
seconds_in_a_day
=
86400
# 60 * 60 * 24
last_second_of_day
=
start_of_day
+
seconds_in_a_day
-
1
# just ask one row to see if we have sth for this date
last_second_of_month
=
start_of_month
+
(
seconds_in_a_day
*
max_day
)
-
1
self
.
cur
.
execute
(
'''
SELECT
kind
FROM logs
SELECT
time
FROM logs
WHERE jid_id = %d
AND time BETWEEN %d AND %d
AND kind NOT IN (%d, %d)
LIMIT 1
'''
%
(
jid_id
,
start_of_
day
,
last_second_of_
day
,
ORDER BY time
'''
%
(
jid_id
,
start_of_
month
,
last_second_of_
month
,
constants
.
KIND_STATUS
,
constants
.
KIND_GCSTATUS
))
result
=
self
.
cur
.
fetchall
()
#Copy all interesant time in a temporary table
self
.
cur
.
execute
(
'
CREATE TEMPORARY TABLE blabla(time,INTEGER)
'
)
for
line
in
result
:
self
.
cur
.
execute
(
'''
INSERT INTO blabla (time) VALUES (%d)
'''
%
(
line
[
0
]))
#then search in this small temp table for each day
for
day
in
xrange
(
1
,
max_day
):
start_of_day
=
self
.
get_unix_time_from_date
(
year
,
month
,
day
)
last_second_of_day
=
start_of_day
+
seconds_in_a_day
-
1
# just ask one row to see if we have sth for this date
self
.
cur
.
execute
(
'''
SELECT time FROM blabla
WHERE time BETWEEN %d AND %d
LIMIT 1
'''
%
(
start_of_day
,
last_second_of_day
))
result
=
self
.
cur
.
fetchone
()
if
result
:
list
[
0
:
0
]
=
[
day
]
#Delete temporary table
self
.
cur
.
execute
(
'
DROP TABLE blabla
'
)
result
=
self
.
cur
.
fetchone
()
if
result
:
return
True
else
:
return
False
return
list
def
get_last_date_that_has_logs
(
self
,
jid
):
'''
returns last time (in seconds since EPOCH) for which
...
...
This diff is collapsed.
Click to expand it.
src/history_window.py
+
6
−
7
View file @
ebccabf5
...
...
@@ -156,13 +156,12 @@ class HistoryWindow:
so it runs progressively! yea :)
asks for days in this month if they have logs it bolds them (marks them)
'''
weekday
,
days_in_this_month
=
calendar
.
monthrange
(
year
,
month
)
# count from 1 (gtk counts from 1), so add 1 more
for
day
in
xrange
(
1
,
days_in_this_month
+
1
):
#print 'ask for logs for date:', year, month, day
if
gajim
.
logger
.
date_has_logs
(
self
.
jid
,
year
,
month
,
day
):
widget
.
mark_day
(
day
)
yield
True
# we have more work to do
yield
False
# we're done with this work
log_days
=
gajim
.
logger
.
get_days_with_logs
(
self
.
jid
,
year
,
month
,
days_in_this_month
)
for
day
in
log_days
:
widget
.
mark_day
(
day
)
yield
True
yield
False
def
on_calendar_month_changed
(
self
,
widget
):
year
,
month
,
day
=
widget
.
get_date
()
# integers
...
...
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