Skip to content

Commit

Permalink
Merge branch 'hotfix/2023-10-23_reinstate_scheduled_journalcsv'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven-Eardley committed Oct 25, 2023
2 parents 3b97419 + e796edc commit 9644185
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion portality/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
12 changes: 9 additions & 3 deletions portality/tasks/journal_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 9644185

Please sign in to comment.