Remove dead code in logger.py method get_search_results_for_query

The method get_search_results_for_query provides a means to search via a
passed in SQL query. This feature has been unused and dead since its initial
commit back in 2005 (commit e542fff69f), so just remove it.
This commit is contained in:
Markus Böhme 2017-02-22 14:50:37 +01:00
parent 65c6a1e7e5
commit 665898864f
1 changed files with 19 additions and 27 deletions

View File

@ -671,33 +671,25 @@ class Logger:
# Error trying to create a new jid_id. This means there is no log # Error trying to create a new jid_id. This means there is no log
return [] return []
if False: # query.startswith('SELECT '): # it's SQL query (FIXME) where_sql, jid_tuple = self._build_contact_where(account, jid)
try: like_sql = '%' + query.replace("'", "''") + '%'
self.cur.execute(query) if year:
except sqlite.OperationalError as e: start_of_day = self.get_unix_time_from_date(year, month, day)
results = [('', '', '', '', str(e))] seconds_in_a_day = 86400 # 60 * 60 * 24
return results last_second_of_day = start_of_day + seconds_in_a_day - 1
self.cur.execute('''
else: # user just typed something, we search in message column SELECT contact_name, time, kind, show, message, subject FROM logs
where_sql, jid_tuple = self._build_contact_where(account, jid) WHERE (%s) AND message LIKE '%s'
like_sql = '%' + query.replace("'", "''") + '%' AND time BETWEEN %d AND %d
if year: ORDER BY time
start_of_day = self.get_unix_time_from_date(year, month, day) ''' % (where_sql, like_sql, start_of_day, last_second_of_day),
seconds_in_a_day = 86400 # 60 * 60 * 24 jid_tuple)
last_second_of_day = start_of_day + seconds_in_a_day - 1 else:
self.cur.execute(''' self.cur.execute('''
SELECT contact_name, time, kind, show, message, subject FROM logs SELECT contact_name, time, kind, show, message, subject FROM logs
WHERE (%s) AND message LIKE '%s' WHERE (%s) AND message LIKE '%s'
AND time BETWEEN %d AND %d ORDER BY time
ORDER BY time ''' % (where_sql, like_sql), jid_tuple)
''' % (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
''' % (where_sql, like_sql), jid_tuple)
results = self.cur.fetchall() results = self.cur.fetchall()
return results return results