diff --git a/app/articles/schemas.py b/app/articles/schemas.py index 3620c49..d4bc201 100644 --- a/app/articles/schemas.py +++ b/app/articles/schemas.py @@ -4,8 +4,8 @@ class Article(APISearchResult): url: str = "" - type: str = "" - first_published: str = "" + type_label: str = "" + # first_published: str = "" image: dict | None = None def __str__(self): diff --git a/app/sources/rosetta/api.py b/app/sources/rosetta/api.py index db7f2f3..c624f77 100644 --- a/app/sources/rosetta/api.py +++ b/app/sources/rosetta/api.py @@ -9,10 +9,11 @@ ) from app.schemas import Filter from config import Config -# from pydash import objects from .lib import RosettaResponseParser, RosettaSourceParser +# from pydash import objects + class RosettaRecords(GetAPI): api_base_url = Config().ROSETTA_API_URL diff --git a/app/sources/website.py b/app/sources/website.py index 5de53c3..b28c61d 100644 --- a/app/sources/website.py +++ b/app/sources/website.py @@ -61,26 +61,17 @@ def get_result(self, page: int | None = 1) -> dict: offset = (page - 1) * self.results_per_page self.add_parameter("offset", offset) self.add_parameter("limit", self.results_per_page) - # self.add_parameter("fields", "search_description,teaser_image_jpg") # TODO: Not all pages have a teaser image - self.add_parameter("fields", "search_description") url = self.build_url() raw_results = self.execute(url) response = ArticleSearchResults() for a in raw_results["items"]: article = Article() article.title = a["title"] - article.url = a["meta"]["html_url"] - article.type = a["meta"]["type"] + article.url = a["full_url"] + article.type_label = a["type_label"] article.id = a["id"] - article.first_published = a["meta"]["first_published_at"] - article.description = a["meta"]["search_description"] - # article.image = a["teaser_image_jpg"] - # TODO: Temp until all pages have a teaser_image - page_details_api = WebsiteArticles() - page_details_url = f"{self.api_base_url}{self.api_path}{article.id}" - page_details = page_details_api.execute(page_details_url) - article.description = page_details["meta"]["search_description"] - article.image = page_details["teaser_image"]["image_jpeg"] + article.description = a["teaser_text"] + article.image = a["teaser_image"] response.results.append(article) response.count = raw_results["meta"]["total_count"] response.results_per_page = self.results_per_page