diff options
Diffstat (limited to 'pydis_site')
-rw-r--r-- | pydis_site/apps/home/models/repository_metadata.py (renamed from pydis_site/apps/home/models/repo_data.py) | 0 | ||||
-rw-r--r-- | pydis_site/apps/home/views/home.py | 7 | ||||
-rw-r--r-- | pydis_site/templates/home/index.html | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/pydis_site/apps/home/models/repo_data.py b/pydis_site/apps/home/models/repository_metadata.py index c975c904..c975c904 100644 --- a/pydis_site/apps/home/models/repo_data.py +++ b/pydis_site/apps/home/models/repository_metadata.py diff --git a/pydis_site/apps/home/views/home.py b/pydis_site/apps/home/views/home.py index c91d13e2..dbd65faf 100644 --- a/pydis_site/apps/home/views/home.py +++ b/pydis_site/apps/home/views/home.py @@ -7,9 +7,10 @@ from pydis_site.apps.home.models import RepositoryMetadata class HomeView(View): - """The view""" + """The main landing page for the website.""" github_api = "https://api.github.com/users/python-discord/repos" + repository_cache_ttl = 600 # Which of our GitHub repos should be displayed on the front page, and in which order? repos = [ @@ -51,8 +52,8 @@ class HomeView(View): try: repo_data = RepositoryMetadata.objects.get(repo_name="python-discord/site") - # If the data is older than 2 minutes, we should refresh it. - if (timezone.now() - repo_data.last_updated).seconds > 120: + # If the data is stale, we should refresh it. + if (timezone.now() - repo_data.last_updated).seconds > self.repository_cache_ttl: # Get new data from API api_repositories = self._get_api_data() diff --git a/pydis_site/templates/home/index.html b/pydis_site/templates/home/index.html index dfb74f96..205e92ff 100644 --- a/pydis_site/templates/home/index.html +++ b/pydis_site/templates/home/index.html @@ -52,7 +52,7 @@ <br> <div class="columns is-multiline"> - {# Display projects from settings.HOMEPAGE_REPOS #} + {# Display projects from HomeView.repos #} {% for repo in repo_data %} <div class="column is-one-third"> <div class="card has-equal-height github-card"> |