Show last month's influence by default.
authorCMDR furrycat <elite@furrycat.net>
Mon, 25 Sep 2017 10:45:22 +0000 (11:45 +0100)
committerCMDR furrycat <elite@furrycat.net>
Mon, 25 Sep 2017 10:46:58 +0000 (11:46 +0100)
Use 'full' to specify all history, or 'from' a specific date.

plugin/faction/faction.py

index 7de21d3..45b13e4 100644 (file)
@@ -1359,14 +1359,20 @@ class Faction(DBConnection):
       params.append(end_date)
     sql += ' group by timestamp, system_name, faction_name order by timestamp desc, system_name, faction_name'
 
+    title = 'Influence'
     if len(faction_ids) == 1:
       key = 'system_name'
       label = 'faction_name'
-      title = 'Influence for {}'.format(names[0])
+      title += ' for {}'.format(names[0])
     else:
       key = 'faction_name'
       label = 'system_name'
-      title = 'Influence in {}'.format(systems[0])
+    if len(system_ids):
+      title += ' in {}'.format(systems[0])
+    if start_date is not None:
+      title += ' from {}'.format(bot.iso8601(start_date)[:10])
+    if end_date is not None:
+      title += ' to {}'.format(bot.iso8601(end_date)[:10])
 
     data = {}
     cursor = self.query(sql, params)
@@ -1459,9 +1465,17 @@ class Faction(DBConnection):
           params['end_date'] = date
         i += 2
         continue
+      elif arg == 'full':
+        params['start_date'] = 0
+        i += 1
+        continue
       params[key].append(args[i])
       i += 1
 
+    if params['start_date'] is None:
+      log.info('Using last 30 days for influence report.  Specify "to" <date> or "all" to override.')
+      params['start_date'] = self.now() - 2592000
+
     num_factions = len(params['names'])
     num_systems = len(params['systems'])
     if num_factions > 1: