Update timestamp when influence is unchanged.
authorCMDR furrycat <elite@furrycat.net>
Wed, 12 Apr 2017 15:47:12 +0000 (16:47 +0100)
committerCMDR furrycat <elite@furrycat.net>
Wed, 12 Apr 2017 15:47:12 +0000 (16:47 +0100)
plugin/faction/faction.py

index e6fd3c3..d44d177 100644 (file)
@@ -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()