From 722c318fecc14a92724d1b343f4a27a9110fe1aa Mon Sep 17 00:00:00 2001 From: Andreas Hubel <andi@saerdnaer.de> Date: Sun, 22 Dec 2024 00:50:12 +0100 Subject: [PATCH] chore(scheduleimport): improve summary generation --- src/core/models/schedules.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/core/models/schedules.py b/src/core/models/schedules.py index ca3ad8650..e9245a6ff 100644 --- a/src/core/models/schedules.py +++ b/src/core/models/schedules.py @@ -839,15 +839,9 @@ class ScheduleSourceImport(models.Model): # create list of unique errors for summary msgs = list({x['message'].split('\n')[0] for x in errors}) - stats = ( - ', '.join( - (t + '=' + str(sum(1 for x in activity if x['action'] == t))) - for t in ['added', 'changed', 'seen', 'deleted', 'missing', 'error', 'skipped'] - ) - + ' \n' - + ' \n'.join(msgs) - ) - self.summary = f"{data.get('version') or ''}\nDONE: {stats}"[:200] + stats = {t: sum(1 for x in activity if x['action'] == t) for t in ['added', 'changed', 'seen', 'deleted', 'missing', 'error', 'skipped']} + stats_str = ', '.join([f'{v}={k}' for (k, v) in stats.items() if v]) + ' \n' + ' \n'.join(msgs) + self.summary = f"{data.get('version') or ''}\nDONE: {stats_str}"[:200] # add debug option to disable abort feature, as it might hide the actual error messages if len(errors) > len(activity) / 2 and self.import_configuration.get('debug') is not True: -- GitLab