From 3743c3d45da893c328cb4756328115dd8a0a36f9 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Mon, 25 Sep 2017 11:45:22 +0100 Subject: [PATCH] Show last month's influence by default. Use 'full' to specify all history, or 'from' a specific date. --- plugin/faction/faction.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugin/faction/faction.py b/plugin/faction/faction.py index 7de21d3..45b13e4 100644 --- a/plugin/faction/faction.py +++ b/plugin/faction/faction.py @@ -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" or "all" to override.') + params['start_date'] = self.now() - 2592000 + num_factions = len(params['names']) num_systems = len(params['systems']) if num_factions > 1: -- 2.7.4