Skip to content

Commit

Permalink
fix: query DB for releas
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobCoffee committed Sep 16, 2024
1 parent c3d1102 commit 25211b5
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions downloads/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down

0 comments on commit 25211b5

Please sign in to comment.