Skip to content

Commit

Permalink
curation: add EURecordCuration job
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlamba committed Nov 28, 2024
1 parent cdf78d9 commit 6bf0300
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions site/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ invenio_search.index_templates =
zenodo_rdm = zenodo_rdm.index_templates
idutils.custom_schemes =
edmo = zenodo_rdm.custom_schemes:get_scheme_config_func
invenio_jobs.jobs =
eu_records_curation = zenodo_rdm.curation.jobs:EURecordCuration

[bdist_wheel]
universal = 1
Expand Down
47 changes: 47 additions & 0 deletions site/zenodo_rdm/curation/jobs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021-2024 CERN.
#
# Invenio-Vocabularies is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
# details.
"""Jobs module."""

from datetime import datetime, timezone

from invenio_jobs.jobs import JobType
from marshmallow import Schema, fields
from marshmallow_utils.fields import ISODateString

from zenodo_rdm.curation.tasks import run_eu_record_curation


class ArgsSchema(Schema):
"""Schema of task input arguments."""

since = ISODateString()
job_arg_schema = fields.String(
metadata={"type": "hidden"},
dump_default="ArgsSchema",
load_default="ArgsSchema",
)


class EURecordCuration(JobType):
"""EU Record Curation Job."""

arguments_schema = ArgsSchema
task = run_eu_record_curation
description = "Curate published records for EU community"
title = "EU Record Curation"
id = "eu_record_curation"

@classmethod
def default_args(cls, job_obj, since=None, **kwargs):
"""Generate default job arguments here."""
if since is None and job_obj.last_runs["success"]:
since = job_obj.last_runs["success"].started_at
else:
since = since or datetime.now(timezone.utc)

return {"since": str(since)}

0 comments on commit 6bf0300

Please sign in to comment.