aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/content
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-08-16 22:09:14 +0400
committerGravatar Hassan Abouelela <[email protected]>2022-08-16 22:09:14 +0400
commit89b0853245fdf5ba7f1f386d7ea7ab1548b538da (patch)
treec87d9ed86e19bb6453e22dff3e4e6b12e00f325e /pydis_site/apps/content
parentBetter Split Up Tag Commit Messages (diff)
Fix Tag Metadata For Static Builds
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'pydis_site/apps/content')
-rw-r--r--pydis_site/apps/content/utils.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/pydis_site/apps/content/utils.py b/pydis_site/apps/content/utils.py
index 7b078de6..e4a24a73 100644
--- a/pydis_site/apps/content/utils.py
+++ b/pydis_site/apps/content/utils.py
@@ -128,8 +128,19 @@ def fetch_tags() -> list[Tag]:
return tags
-def set_tag_commit(tag: Tag) -> Tag:
+def set_tag_commit(tag: Tag) -> None:
"""Fetch commit information from the API, and save it for the tag."""
+ if settings.STATIC_BUILD:
+ # Static builds request every page during build, which can ratelimit it.
+ # Instead, we return some fake data.
+ tag.last_commit = Commit(
+ sha="68da80efc00d9932a209d5cccd8d344cec0f09ea",
+ message="Initial Commit\n\nTHIS IS FAKE DEMO DATA",
+ date=datetime.datetime(2018, 2, 3, 12, 20, 26, tzinfo=datetime.timezone.utc),
+ author=json.dumps([{"name": "Joseph", "email": "[email protected]"}]),
+ )
+ return
+
path = "/bot/resources/tags"
if tag.group:
path += f"/{tag.group}"
@@ -161,8 +172,6 @@ def set_tag_commit(tag: Tag) -> Tag:
tag.last_commit = commit_obj
tag.save()
- return tag
-
def record_tags(tags: list[Tag]) -> None:
"""Sync the database with an updated set of tags."""