select last day we have logs for in history browser
This commit is contained in:
parent
f9543aed35
commit
e162e5daed
|
@ -339,13 +339,14 @@ class Logger:
|
||||||
SELECT contact_name, time, kind, show, message, subject FROM logs
|
SELECT contact_name, time, kind, show, message, subject FROM logs
|
||||||
WHERE jid_id = ? AND message LIKE ?
|
WHERE jid_id = ? AND message LIKE ?
|
||||||
ORDER BY time
|
ORDER BY time
|
||||||
''', (jid_id,like_sql))
|
''', (jid_id, like_sql))
|
||||||
|
|
||||||
results = cur.fetchall()
|
results = cur.fetchall()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def date_has_logs(self, jid, year, month, day):
|
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 = jid.lower()
|
||||||
jid_id = self.get_jid_id(jid)
|
jid_id = self.get_jid_id(jid)
|
||||||
|
|
||||||
|
@ -362,8 +363,22 @@ class Logger:
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
''' % (jid_id, start_of_day, last_second_of_day,
|
''' % (jid_id, start_of_day, last_second_of_day,
|
||||||
constants.KIND_STATUS, constants.KIND_GCSTATUS))
|
constants.KIND_STATUS, constants.KIND_GCSTATUS))
|
||||||
results = cur.fetchone()
|
result = cur.fetchone()
|
||||||
if results:
|
if result:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
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('foreground', 'grey')
|
||||||
tag.set_property('justification', gtk.JUSTIFY_CENTER)
|
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]
|
y, m, d = date[0], date[1], date[2]
|
||||||
|
self.calendar.select_day(d)
|
||||||
self.add_lines_for_date(y, m, d)
|
self.add_lines_for_date(y, m, d)
|
||||||
|
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
|
|
Loading…
Reference in New Issue