-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)} |