Merge branch 'fix-additional_data-loading' into 'master'

Fix loading of additional_data column from log database

See merge request !72
This commit is contained in:
Philipp Hörist 2017-03-25 22:19:29 +01:00
commit 6b34ea957e
1 changed files with 13 additions and 7 deletions

View File

@ -609,13 +609,16 @@ class Logger:
restore_how_many_rows, pending_how_many), jid_tuple) restore_how_many_rows, pending_how_many), jid_tuple)
results = self.cur.fetchall() results = self.cur.fetchall()
messages = []
for entry in results: for entry in results:
entry = list(entry) additional_data = json.loads(entry[4])
entry[4] = json.loads(entry[4]) parsed_entry = entry[:4] + (additional_data, ) + entry[5:]
messages.append(parsed_entry)
except sqlite.DatabaseError: except sqlite.DatabaseError:
raise exceptions.DatabaseMalformed raise exceptions.DatabaseMalformed
results.reverse()
return results messages.reverse()
return messages
def get_unix_time_from_date(self, year, month, day): def get_unix_time_from_date(self, year, month, day):
# year (fe 2005), month (fe 11), day (fe 25) # year (fe 2005), month (fe 11), day (fe 25)
@ -655,10 +658,13 @@ class Logger:
''' % (where_sql, start_of_day, last_second_of_day), jid_tuple) ''' % (where_sql, start_of_day, last_second_of_day), jid_tuple)
results = self.cur.fetchall() results = self.cur.fetchall()
messages = []
for entry in results: for entry in results:
entry = list(entry) additional_data = json.loads(entry[6])
entry[6] = json.loads(entry[6]) parsed_entry = entry[:6] + (additional_data, ) + entry[7:]
return results messages.append(parsed_entry)
return messages
def get_search_results_for_query(self, jid, query, account, year=False, def get_search_results_for_query(self, jid, query, account, year=False,
month=False, day=False): month=False, day=False):