changeset 2cbde8d17b8c in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=2cbde8d17b8c description: optimize history search. Fixes #6997
diffstat:
data/gui/history_window.ui | 20 +++++++++++++++++++- src/common/logger.py | 17 +++++++++++++++-- src/history_window.py | 8 +++++++- 3 files changed, 41 insertions(+), 4 deletions(-)
diffs (105 lines):
diff -r 311f32ef6fc6 -r 2cbde8d17b8c data/gui/history_window.ui --- a/data/gui/history_window.ui Sun Dec 18 17:14:30 2011 +0100 +++ b/data/gui/history_window.ui Sun Dec 18 21:28:47 2011 +0400 @@ -80,6 +80,21 @@ <property name="position">2</property> </packing> </child> + <child> + <object class="GtkCheckButton" id="search_in_date"> + <property name="label" translatable="yes">_In date search</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -104,14 +119,17 @@ <object class="GtkCalendar" id="calendar"> <property name="visible">True</property> <property name="can_focus">True</property> + <signal name="month_changed" handler="on_calendar_month_changed"/> <signal name="day_selected" handler="on_calendar_day_selected"/> - <signal name="month_changed" handler="on_calendar_month_changed"/> </object> <packing> <property name="expand">False</property> <property name="position">0</property> </packing> </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="resize">False</property> diff -r 311f32ef6fc6 -r 2cbde8d17b8c src/common/logger.py --- a/src/common/logger.py Sun Dec 18 17:14:30 2011 +0100 +++ b/src/common/logger.py Sun Dec 18 21:28:47 2011 +0400 @@ -629,7 +629,8 @@ results = self.cur.fetchall() return results
- def get_search_results_for_query(self, jid, query, account): + def get_search_results_for_query(self, jid, query, account, year=False, + month=False, day=False): """ Returns contact_name, time, kind, show, message
@@ -652,7 +653,19 @@ else: # user just typed something, we search in message column where_sql, jid_tuple = self._build_contact_where(account, jid) like_sql = '%' + query.replace("'", "''") + '%' - self.cur.execute(''' + if year: + start_of_day = self.get_unix_time_from_date(year, month, day) + seconds_in_a_day = 86400 # 60 * 60 * 24 + last_second_of_day = start_of_day + seconds_in_a_day - 1 + self.cur.execute(''' + SELECT contact_name, time, kind, show, message, subject FROM logs + WHERE (%s) AND message LIKE '%s' + AND time BETWEEN %d AND %d + ORDER BY time + ''' % (where_sql, like_sql, start_of_day, last_second_of_day), + jid_tuple) + else: + self.cur.execute(''' SELECT contact_name, time, kind, show, message, subject FROM logs WHERE (%s) AND message LIKE '%s' ORDER BY time diff -r 311f32ef6fc6 -r 2cbde8d17b8c src/history_window.py --- a/src/history_window.py Sun Dec 18 17:14:30 2011 +0100 +++ b/src/history_window.py Sun Dec 18 21:28:47 2011 +0400 @@ -83,6 +83,7 @@ self.query_combobox.set_active(0) self.results_treeview = xml.get_object('results_treeview') self.results_window = xml.get_object('results_scrolledwindow') + self.search_in_date = xml.get_object('search_in_date')
# contact_name, date, message, time model = gtk.ListStore(str, str, str, str, str) @@ -511,9 +512,14 @@ # This may leed to wrong self nick in the displayed history (Uggh!) account = gajim.contacts.get_accounts()[0]
+ year, month, day = False, False, False + if self.search_in_date.get_active(): + year, month, day = self.calendar.get_date() # integers + month = gtkgui_helpers.make_gtk_month_python_month(month) + # contact_name, time, kind, show, message, subject results = gajim.logger.get_search_results_for_query( - jid, text, account) + jid, text, account, year, month, day) #FIXME: # add "subject: | message: " in message column if kind is single # also do we need show at all? (we do not search on subject)