Skip to content
Snippets Groups Projects
Commit e162e5da authored by nkour's avatar nkour
Browse files

select last day we have logs for in history browser

parent f9543aed
No related branches found
No related tags found
No related merge requests found
......@@ -339,13 +339,14 @@ class Logger:
SELECT contact_name, time, kind, show, message, subject FROM logs
WHERE jid_id = ? AND message LIKE ?
ORDER BY time
''', (jid_id,like_sql))
''', (jid_id, like_sql))
results = cur.fetchall()
return results
def date_has_logs(self, jid, year, month, day):
'''returns True if we have logs for given day, else False'''
'''returns True if we have logs (excluding statuses) for given date,
else False'''
jid = jid.lower()
jid_id = self.get_jid_id(jid)
......@@ -362,8 +363,22 @@ class Logger:
LIMIT 1
''' % (jid_id, start_of_day, last_second_of_day,
constants.KIND_STATUS, constants.KIND_GCSTATUS))
results = cur.fetchone()
if results:
result = cur.fetchone()
if result:
return True
else:
return False
def get_last_date_that_has_logs(self, jid):
'''returns last time (in seconds since EPOCH) for which
we had logs (excluding statuses)'''
jid = jid.lower()
jid_id = self.get_jid_id(jid)
cur.execute('''
SELECT time FROM logs
WHERE jid_id = ?
AND kind NOT IN (?, ?)
ORDER BY time DESC LIMIT 1
''', (jid_id, constants.KIND_STATUS, constants.KIND_GCSTATUS))
result = cur.fetchone()
return result
......@@ -117,8 +117,16 @@ class HistoryWindow:
tag.set_property('foreground', 'grey')
tag.set_property('justification', gtk.JUSTIFY_CENTER)
date = time.localtime()
# select and show logs for last date we have logs with contact
# and if we don't have logs at all, default to today
result = gajim.logger.get_last_date_that_has_logs(self.jid)
tim = result[0]
if tim != '':
date = time.localtime(tim)
else:
date = time.localtime()
y, m, d = date[0], date[1], date[2]
self.calendar.select_day(d)
self.add_lines_for_date(y, m, d)
self.window.show_all()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment