Skip to content

feat(mapper): Set publication date based on resource type - #595

Open
sakshamarora1 wants to merge 1 commit into
CERNDocumentServer:masterfrom
sakshamarora1:fix/dates_mapping
Open

feat(mapper): Set publication date based on resource type#595
sakshamarora1 wants to merge 1 commit into
CERNDocumentServer:masterfrom
sakshamarora1:fix/dates_mapping

Conversation

@sakshamarora1

Copy link
Copy Markdown
Contributor

fixes: #581

publication_date = normalize(publication_date_str)

return publication_date
store_priority_date(self, "article", publication_date)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if this is done a bit cleaner, because this additional nested key is making things more complex.
let's map 260__c as publication_date (as is) and 269__c as preprint_date, then please check my comment in the mapper as next

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah makes sense, I have updated the PR accordingly

Comment on lines +79 to +82
priority_dates = dojson_entry.pop("_publication_date_candidates", {})
article_date = priority_dates.get("article")
preprint_date = priority_dates.get("preprint")
resource_type = (dojson_entry.get("resource_type") or {}).get("id")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of nested _publication_date_candidates, could you use publication_date and preprint date here? it will be very similar in logic but you will not need the check in line 113
so basically

pub_date = dojson_entry["publication_date"]
if (restype != "article" and is_more_accurate(dojson_entry["preprint_date"])) or restype=="preprint": 
    pub_date = dojson_entry["preprint_date"]

Comment on lines +103 to +111
if resource_type == "publication-article":
if preprint_date:
dojson_entry.setdefault("dates", []).append(
{
"date": preprint_date,
"type": {"id": "submitted"},
"description": "preprint",
}
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible there’s only 269 (no 260)? In this case if there is no 260 preprint is moved to secondary dates and publication_date falls back to status week / file creation

Comment on lines +63 to +67
def _date_precision(date_str):
"""Return how granular a normalized date string is (year=1, month=2, day=3)."""
if not date_str:
return 0
return len(date_str.split("-"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're not always return in the format with "-" so maybe we should change that? or we can split with "-" and "/". See the date normalize method

example:

  • for non-articles, if 260 is "2021" and 269 is "2021/05":
  • precision(preprint="2021/05") = 1
  • precision(pub="2021") = 1
  • _is_more_accurate is False → 260 wins, even though 269 is month-level and should win.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dates mappings - preprint vs article

3 participants