diff options
-rw-r--r-- | pydis_site/apps/content/urls.py | 2 | ||||
-rw-r--r-- | pydis_site/apps/content/utils.py | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/pydis_site/apps/content/urls.py b/pydis_site/apps/content/urls.py index 163d05bc..a7695a27 100644 --- a/pydis_site/apps/content/urls.py +++ b/pydis_site/apps/content/urls.py @@ -40,6 +40,8 @@ def get_all_pages() -> DISTILL_RETURN: def get_all_tags() -> DISTILL_RETURN: """Return all tag names and groups in static builds.""" + # We instantiate the set with None here to make filtering it out later easier + # whether it was added in the loop or not groups = {None} for tag in utils.get_tags_static(): groups.add(tag.group) diff --git a/pydis_site/apps/content/utils.py b/pydis_site/apps/content/utils.py index 8c9ad036..c12893ef 100644 --- a/pydis_site/apps/content/utils.py +++ b/pydis_site/apps/content/utils.py @@ -175,19 +175,19 @@ def record_tags(tags: list[Tag]) -> None: Tag.objects.exclude(name__in=[tag.name for tag in tags]).delete() # Insert/update the tags - for tag in tags: + for new_tag in tags: try: - old_tag = Tag.objects.get(name=tag.name) + old_tag = Tag.objects.get(name=new_tag.name) except Tag.DoesNotExist: # The tag is not in the database yet, # pretend it's previous state is the current state - old_tag = tag + old_tag = new_tag - if old_tag.sha == tag.sha and old_tag.last_commit is not None: + if old_tag.sha == new_tag.sha and old_tag.last_commit is not None: # We still have an up-to-date commit entry - tag.last_commit = old_tag.last_commit + new_tag.last_commit = old_tag.last_commit - tag.save() + new_tag.save() # Drop old, unused commits Commit.objects.filter(tag__isnull=True).delete() |