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

Commit

Permalink
Change some field names
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Jan 15, 2024
1 parent 3e719fb commit 6c0110c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def create_app():
config = Config()
app = FastAPI(log_level=config.LOG_LEVEL)
app = FastAPI(title="ETNA Search API", log_level=config.LOG_LEVEL)
base_uri = "/api/v1"

@app.get("/healthcheck/live/", include_in_schema=False)
Expand Down
6 changes: 4 additions & 2 deletions app/records/schemas/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ class RecordArchive(Details):
type: str = "archive"
name: str = ""
archon: str = ""
opening_hours: str = ""
opening_times: str = ""
disabled_access: str = ""
place_information: str = ""
information: str = ""
fee: str = ""
appointment: str = ""
contact_info: dict = {}
places: list[str] = []
agents: dict = {}
Expand Down
8 changes: 5 additions & 3 deletions app/sources/rosetta/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ def parse_results(self, raw_results, source_url):
record = RecordArchive(parsed_data.id())
record.name = parsed_data.title()
record.archon = parsed_data.reference_number()
record.opening_hours = parsed_data.opening_hours()
record.disabled_access = parsed_data.disabled_access()
record.place_information = parsed_data.place_comments()
record.opening_times = parsed_data.place_opening_times()
record.disabled_access = parsed_data.place_disabled_access()
record.information = parsed_data.place_comments()
record.fee = parsed_data.place_fee()
record.appointment = parsed_data.place_appointment()
record.places = parsed_data.places()
record.contact_info = parsed_data.contact_info()
record.agents = parsed_data.agents()
Expand Down
34 changes: 26 additions & 8 deletions app/sources/rosetta/lib/response_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,18 @@ def place_descriptions(self) -> list[str]:
and "label" in place["description"]
and "value" in place["description"]["label"]
]
return []
return ""

def opening_hours(self):
def place_opening_times(self) -> str:
if "place" in self.source:
for place in self.source["place"]:
if "description" in place and "value" in place["description"]:
document = PyQuery(place["description"]["value"])
if opening_hours := document("span.openinghours").text():
return opening_hours
return []
if opening_times := document("span.openinghours").text():
return opening_times
return ""

def disabled_access(self):
def place_disabled_access(self) -> str:
if "place" in self.source:
for place in self.source["place"]:
if "description" in place and "value" in place["description"]:
Expand All @@ -257,15 +257,33 @@ def disabled_access(self):
"span.disabledaccess"
).text():
return disabled_access
return []
return ""

def place_comments(self):
def place_comments(self) -> str:
if "place" in self.source:
for place in self.source["place"]:
if "description" in place and "value" in place["description"]:
document = PyQuery(place["description"]["value"])
if comments := document("span.comments").text():
return comments
return ""

def place_fee(self) -> str:
if "place" in self.source:
for place in self.source["place"]:
if "description" in place and "value" in place["description"]:
document = PyQuery(place["description"]["value"])
if fee := document("span.fee").text():
return fee
return ""

def place_appointment(self) -> str:
if "place" in self.source:
for place in self.source["place"]:
if "description" in place and "value" in place["description"]:
document = PyQuery(place["description"]["value"])
if appointment := document("span.appointment").text():
return appointment
return []

def gender(self) -> str:
Expand Down

0 comments on commit 6c0110c

Please sign in to comment.