From 25211b588e24c855547e5a5bba94f99ef3fd7bdb Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Mon, 16 Sep 2024 15:51:43 -0500 Subject: [PATCH] fix: query DB for releas --- downloads/views.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/downloads/views.py b/downloads/views.py index 084e46b7d..9364f5d00 100644 --- a/downloads/views.py +++ b/downloads/views.py @@ -183,19 +183,10 @@ def get_feed(self, obj: Any, request: WSGIRequest) -> Feed: self.request = request return super().get_feed(obj, request) - def items(self) -> list[dict[str, Any]]: + @staticmethod + def items() -> list[dict[str, Any]]: """Return the latest Python releases.""" - url = self.create_url("/api/v2/downloads/release/") - logger.info(f"Fetching releases from: {url}") - try: - return self._fetch_releases(url) - except requests.RequestException as e: - logger.error(f"Error fetching releases from API: {str(e)}") - except ValueError as e: - logger.error(f"Error parsing JSON from API response: {str(e)}") - except Exception as e: - logger.error(f"Unexpected error in items method: {str(e)}") - return [] + return Release.objects.filter(is_published=True).order_by('-release_date')[:10] @staticmethod def _fetch_releases(url: str) -> list[dict[str, Any]]: