comparison sat/memory/sqlite.py @ 3191:7255286a298a

memory (sqlite): don't store empty messages
author Goffi <goffi@goffi.org>
date Wed, 26 Feb 2020 22:03:15 +0100
parents 330a5f1d9eea
children 780fb8dd07ef
comparison
equal deleted inserted replaced
3190:1c6dacbfcf27 3191:7255286a298a
440 # now we can add message and subject 440 # now we can add message and subject
441 uid = data['uid'] 441 uid = data['uid']
442 d_list = [] 442 d_list = []
443 for key in ('message', 'subject'): 443 for key in ('message', 'subject'):
444 for lang, value in data[key].items(): 444 for lang, value in data[key].items():
445 if not value.strip():
446 # no need to store empty messages
447 continue
445 d = self.dbpool.runQuery( 448 d = self.dbpool.runQuery(
446 "INSERT INTO {key}(history_uid, {key}, language) VALUES (?,?,?)" 449 "INSERT INTO {key}(history_uid, {key}, language) VALUES (?,?,?)"
447 .format(key=key), 450 .format(key=key),
448 (uid, value, lang or None)) 451 (uid, value, lang or None))
449 d.addErrback(lambda __: log.error( 452 d.addErrback(lambda __: log.error(