aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/home
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2021-10-06 23:20:56 +0200
committerGravatar Johannes Christ <[email protected]>2021-10-06 23:22:45 +0200
commitce75197fc1d0b2086631277d29f9396908bdc86c (patch)
tree2eab9855ab1a83352a5d83050d8a1fc0524f3285 /pydis_site/apps/home
parentMerge branch 'main' into subdomains-to-query-paths (diff)
parentMerge pull request #599 from python-discord/fix-http-links (diff)
Merge branch 'master' into subdomains-to-query-paths
Diffstat (limited to 'pydis_site/apps/home')
-rw-r--r--pydis_site/apps/home/tests/mock_github_api_response.json2
-rw-r--r--pydis_site/apps/home/views/home.py17
2 files changed, 13 insertions, 6 deletions
diff --git a/pydis_site/apps/home/tests/mock_github_api_response.json b/pydis_site/apps/home/tests/mock_github_api_response.json
index ddbffed8..3b0a7078 100644
--- a/pydis_site/apps/home/tests/mock_github_api_response.json
+++ b/pydis_site/apps/home/tests/mock_github_api_response.json
@@ -21,7 +21,7 @@
"forks_count": 31
},
{
- "full_name": "python-discord/django-simple-bulma",
+ "full_name": "python-discord/king-arthur",
"description": "test",
"stargazers_count": 97,
"language": "Python",
diff --git a/pydis_site/apps/home/views/home.py b/pydis_site/apps/home/views/home.py
index 0f26cef3..401c768f 100644
--- a/pydis_site/apps/home/views/home.py
+++ b/pydis_site/apps/home/views/home.py
@@ -9,7 +9,7 @@ from django.utils import timezone
from django.views import View
from pydis_site.apps.home.models import RepositoryMetadata
-from pydis_site.constants import GITHUB_TOKEN
+from pydis_site.constants import GITHUB_TOKEN, TIMEOUT_PERIOD
log = logging.getLogger(__name__)
@@ -27,7 +27,7 @@ class HomeView(View):
"python-discord/snekbox",
"python-discord/sir-lancebot",
"python-discord/metricity",
- "python-discord/django-simple-bulma",
+ "python-discord/king-arthur",
]
def __init__(self):
@@ -51,9 +51,16 @@ class HomeView(View):
If we're unable to get that info for any reason, return an empty dict.
"""
repo_dict = {}
-
- # Fetch the data from the GitHub API
- api_data: List[dict] = requests.get(self.github_api, headers=self.headers).json()
+ try:
+ # Fetch the data from the GitHub API
+ api_data: List[dict] = requests.get(
+ self.github_api,
+ headers=self.headers,
+ timeout=TIMEOUT_PERIOD
+ ).json()
+ except requests.exceptions.Timeout:
+ log.error("Request to fetch GitHub repository metadata for timed out!")
+ return repo_dict
# Process the API data into our dict
for repo in api_data: