Skip to content
Snippets Groups Projects
Commit 5c615f53 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

clean logs table so that show field contains only 0, 1, 2, 3, 4, 5 values

parent 18296324
No related branches found
No related tags found
No related merge requests found
......@@ -141,7 +141,7 @@ class Config:
'send_on_ctrl_enter': [opt_bool, False, _('Send message on Ctrl+Enter and with Enter make new line (Mirabilis ICQ Client default behaviour).')],
'show_roster_on_startup': [opt_bool, True],
'key_up_lines': [opt_int, 25, _('How many lines to store for Ctrl+KeyUP.')],
'version': [ opt_str, '0.10.1.4' ], # which version created the config
'version': [ opt_str, '0.10.1.5' ], # which version created the config
'search_engine': [opt_str, 'http://www.google.com/search?&q=%s&sourceid=gajim'],
'dictionary_url': [opt_str, 'WIKTIONARY', _("Either custom url with %s in it where %s is the word/phrase or 'WIKTIONARY' which means use wiktionary.")],
'always_english_wikipedia': [opt_bool, False],
......
......@@ -147,6 +147,8 @@ class OptionsParser:
self.update_config_to_01013()
if old < [0, 10, 1, 4] and new >= [0, 10, 1, 4]:
self.update_config_to_01014()
if old < [0, 10, 1, 5] and new >= [0, 10, 1, 5]:
self.update_config_to_01015()
gajim.logger.init_vars()
gajim.config.set('version', new_version)
......@@ -315,13 +317,32 @@ class OptionsParser:
con = sqlite.connect(logger.LOG_DB_PATH)
cur = con.cursor()
# apply indeces
cur.executescript(
'''
CREATE INDEX idx_logs_jid_id_kind ON logs (jid_id, kind);
CREATE INDEX idx_unread_messages_jid_id ON unread_messages (jid_id);
'''
)
try:
cur.executescript(
'''
CREATE INDEX idx_logs_jid_id_kind ON logs (jid_id, kind);
CREATE INDEX idx_unread_messages_jid_id ON unread_messages (jid_id);
'''
)
con.commit()
con.commit()
except:
pass
con.close()
gajim.config.set('version', '0.10.1.4')
def update_config_to_01015(self):
'''clean show values in logs database'''
from pysqlite2 import dbapi2 as sqlite
import logger
con = sqlite.connect(logger.LOG_DB_PATH)
cur = con.cursor()
status = dict((i[5:].lower(), logger.constants.__dict__[i]) for i in \
logger.constants.__dict__.keys() if i.startswith('SHOW_'))
for show in status:
cur.execute('update logs set show = ? where show = ?;', (status[show],
show))
cur.executescript('update logs set show = NULL where show not in (0, 1, 2, 3, 4, 5);')
con.commit()
con.close()
gajim.config.set('version', '0.10.1.5')
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