Skip to content

Commit

Permalink
curation: fix rules; fix curator evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlamba authored and slint committed Dec 9, 2024
1 parent 4257fa9 commit 73f57cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions site/zenodo_rdm/curation/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@

CURATION_HIGH_CONF_KEYWORDS_EU = []
"""High confidence keywords for EU records."""

CURATION_TEST_PHRASES = []
"""Test record phrases."""
2 changes: 1 addition & 1 deletion site/zenodo_rdm/curation/curators.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _evaluator(self, results):
rule_score = current_curation.scores.get(rule)
if result is None:
continue
elif isinstance(rule_score, int):
elif type(rule_score) is int:
score += rule_score if result else 0
elif isinstance(rule_score, bool):
if result:
Expand Down
12 changes: 7 additions & 5 deletions site/zenodo_rdm/curation/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def award_acronym_in_title(record):
"""Check if EU award name in record title."""
award_service = current_service_registry.get("awards")
title = record.metadata["title"]
funding = record.metadata["funding"]

funding = record.metadata.get("funding", [])
for f in funding:
if f["funder"]["id"] == "00k4n6c32":
if f["funder"].get("id") == "00k4n6c32":
if award_id := f.get("award", {}).get("id"):
award = award_service.record_cls.pid.resolve(award_id)
if award.get("acronym") and (
Expand All @@ -64,12 +64,14 @@ def published_before_award_start(record):
"""Check if published before award start date."""
award_service = current_service_registry.get("awards")

for f in record.metadata["funding"]:
if f["funder"]["id"] == "00k4n6c32":
funding = record.metadata.get("funding", [])
for f in funding:
if f["funder"].get("id") == "00k4n6c32":
if award_id := f.get("award", {}).get("id"):
award = award_service.record_cls.pid.resolve(award_id)
if award.get("start_date") and (
record.created < arrow.get(award.get("start_date")).datetime
record.created.timestamp()
< arrow.get(award.get("start_date")).datetime.timestamp()
):
return True
return False
Expand Down

0 comments on commit 73f57cd

Please sign in to comment.