Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
Use display_title if available
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Jan 18, 2024
1 parent 3b0fba3 commit e55ce99
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/records/schemas/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Record(Details):
iaid: str | None = None
former_ref: str | None = None
title: str | None = None
summary_title: str | None = None
description: str | None = None
date: str | None = None
is_digitised: bool | None = None
Expand All @@ -40,6 +41,7 @@ class Aggregation(Details):
ref: str | None = None
iaid: str | None = None
title: str | None = None
summary_title: str | None = None
description: str | None = None
physical_description: str | None = None
administrative_background: str | None = None
Expand Down
2 changes: 2 additions & 0 deletions app/sources/rosetta/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def parse_results(self, raw_results, source_url):
record.iaid = parsed_data.iaid()
record.former_ref = parsed_data.former_identifier()
record.title = parsed_data.title()
record.summary_title = parsed_data.summary_title()
record.description = parsed_data.description()
record.date = parsed_data.date_range()
record.is_digitised = parsed_data.is_digitised()
Expand All @@ -112,6 +113,7 @@ def parse_results(self, raw_results, source_url):
record.ref = parsed_data.identifier()
record.iaid = parsed_data.iaid()
record.title = parsed_data.title()
record.summary_title = parsed_data.summary_title()
record.description = parsed_data.description()
record.physical_description = parsed_data.physical_description()
record.administrative_background = (
Expand Down
16 changes: 14 additions & 2 deletions app/sources/rosetta/lib/response_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,19 @@ def is_tna(self) -> bool:
return self.is_digitised() or False

def title(self) -> str:
if summary_title := self.summary_title():
return summary_title
if "title" in self.source:
if display_title := next(
(
item["label"]["value"]
for item in self.source["title"]
if "label" in item
and "value" in item["label"]
and "type" in item["label"]
and item["label"]["type"] == "display"
),
None,
):
return display_title
if title := next(
(
item["value"]
Expand All @@ -113,6 +123,8 @@ def title(self) -> str:
return title
if name := self.name():
return name
if summary_title := self.summary_title():
return summary_title
if description := self.description():
return description
return ""
Expand Down

0 comments on commit e55ce99

Please sign in to comment.