From e796edcf549756d1de6f0c535f475787a0e82aed Mon Sep 17 00:00:00 2001 From: Steve Eardley Date: Mon, 23 Oct 2023 18:18:39 +0100 Subject: [PATCH] Reduce logging via config and reinstate journalcsv schedule --- portality/settings.py | 5 ++++- portality/tasks/journal_csv.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/portality/settings.py b/portality/settings.py index cf19eaaaa2..92284bd2be 100644 --- a/portality/settings.py +++ b/portality/settings.py @@ -423,11 +423,14 @@ # Crontab for never running a job - February 31st (use to disable tasks) CRON_NEVER = {"month": "2", "day": "31", "day_of_week": "*", "hour": "*", "minute": "*"} +# Additional Logging for scheduled JournalCSV +EXTRA_JOURNALCSV_LOGGING = False + # Crontab schedules must be for unique times to avoid delays due to perceived race conditions HUEY_SCHEDULE = { "sitemap": {"month": "*", "day": "*", "day_of_week": "*", "hour": "8", "minute": "0"}, "reporting": {"month": "*", "day": "1", "day_of_week": "*", "hour": "0", "minute": "0"}, - "journal_csv": CRON_NEVER, # {"month": "*", "day": "*", "day_of_week": "*", "hour": "*", "minute": "20"}, + "journal_csv": {"month": "*", "day": "*", "day_of_week": "*", "hour": "*", "minute": "20"}, "read_news": {"month": "*", "day": "*", "day_of_week": "*", "hour": "*", "minute": "30"}, "article_cleanup_sync": {"month": "*", "day": "2", "day_of_week": "*", "hour": "0", "minute": "0"}, "async_workflow_notifications": {"month": "*", "day": "*", "day_of_week": "1", "hour": "5", "minute": "0"}, diff --git a/portality/tasks/journal_csv.py b/portality/tasks/journal_csv.py index 9b5b74269d..153a13735e 100644 --- a/portality/tasks/journal_csv.py +++ b/portality/tasks/journal_csv.py @@ -19,12 +19,18 @@ def run(self): def logger(msg): self.background_job.add_audit_message(msg) + _l = logger if app.config.get('EXTRA_JOURNALCSV_LOGGING', False) else None + job = self.background_job journalService = DOAJ.journalService() - url, action_register = journalService.csv(logger=logger) - # for ar in action_register: - # job.add_audit_message(ar) + url, action_register = journalService.csv(logger=_l) + + # Log directly to the task if we don't have extra logging configured + if _l is None: + for ar in action_register: + job.add_audit_message(ar) + job.add_audit_message("CSV generated; will be served from {y}".format(y=url)) def cleanup(self):