From 33eaaca11b739522b17407cb90658f7c19cb9165 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Wed, 12 Apr 2017 16:47:12 +0100 Subject: [PATCH] Update timestamp when influence is unchanged. --- plugin/faction/faction.py | 7 +++++++ 1 file changed, 7 insertions(+) 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() -- 2.7.4