aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/home/views/home.py
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2021-07-15 20:44:52 +0200
committerGravatar Johannes Christ <[email protected]>2021-07-15 20:44:52 +0200
commit3a1f4230cc9f660ff118f9bbf5591ea8aa87ef07 (patch)
treeec39ba66c6d86b2560ad55a6fef7050747b5a8ed /pydis_site/apps/home/views/home.py
parentImprovements & fixes to homepage repository display. (diff)
Address review comment.
Diffstat (limited to 'pydis_site/apps/home/views/home.py')
-rw-r--r--pydis_site/apps/home/views/home.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/pydis_site/apps/home/views/home.py b/pydis_site/apps/home/views/home.py
index 23b6ab24..0f26cef3 100644
--- a/pydis_site/apps/home/views/home.py
+++ b/pydis_site/apps/home/views/home.py
@@ -84,10 +84,13 @@ class HomeView(View):
def _get_repo_data(self) -> List[RepositoryMetadata]:
"""Build a list of RepositoryMetadata objects that we can use to populate the front page."""
# First off, load the timestamp of the least recently updated entry.
- oldest_entry = RepositoryMetadata.objects.order_by("last_updated").first()
+ last_update = (
+ RepositoryMetadata.objects.values_list("last_updated", flat=True)
+ .order_by("last_updated").first()
+ )
# If we did not retrieve any results here, we should import them!
- if oldest_entry is None:
+ if last_update is None:
# Try to get new data from the API. If it fails, we'll return an empty list.
# In this case, we simply don't display our projects on the site.
@@ -106,7 +109,7 @@ class HomeView(View):
)
# If the data is stale, we should refresh it.
- if (timezone.now() - oldest_entry.last_updated).seconds > self.repository_cache_ttl:
+ if (timezone.now() - last_update).seconds > self.repository_cache_ttl:
# Try to get new data from the API. If it fails, return the cached data.
api_repositories = self._get_api_data()