From: CMDR furrycat Date: Wed, 12 Apr 2017 15:47:12 +0000 (+0100) Subject: Update timestamp when influence is unchanged. X-Git-Url: http://git.furryclan.net/?a=commitdiff_plain;h=33eaaca11b739522b17407cb90658f7c19cb9165;p=furrycat%2Fcatbot.git Update timestamp when influence is unchanged. --- diff --git a/plugin/faction/faction.py b/plugin/faction/faction.py index e6fd3c3..d44d177 100644 --- a/plugin/faction/faction.py +++ b/plugin/faction/faction.py @@ -737,6 +737,7 @@ class Faction(DBConnection): checksum = m.hexdigest() log.info('Updating influence in {}: {}'.format(system, influence)) + update = False for faction in factions: state_id = eddb.get_state_id(faction['FactionState']) if state_id is None: @@ -746,6 +747,12 @@ class Faction(DBConnection): cursor = self.query('insert or ignore into faction_influence values (?, ?, ?, ?, ?, ?)', [checksum, system_id, timestamp, faction_id, faction['Influence'], state_id]) if not cursor.rowcount: log.debug('No update for {} with checksum {}'.format(system, checksum)) + update = True + if update: + # We need a value for faction_id to use the index. + cursor = self.query('update faction_influence set timestamp=? where checksum=? and eddb_id=? and faction_id>0', [timestamp, checksum, system_id]) + if not cursor.rowcount: + log.warning('Failed to update timestamp for {} with checksum {}'.format(system, checksum)) self.dbh.commit() self.close_db()