Skip to content

Commit

Permalink
Rewrite DB query to return Pages directly
Browse files Browse the repository at this point in the history
  • Loading branch information
chris34 committed Nov 25, 2024
1 parent ba51c16 commit 71fb001
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions inyoka/wiki/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,12 @@ def update_related_pages(self, update_meta: bool=True) -> None:
Intended to be run in a celery task.
"""
related_pages = MetaData.objects.select_related('page__last_rev__text') \
.filter(key__in=('X-Link', 'X-Attach'), value=self.name)

for meta in related_pages:
p = meta.page
related_pages = Page.objects.select_related('last_rev__text') \
.filter(metadata__key__in=('X-Link', 'X-Attach'),
metadata__value=self.name)

for p in related_pages:
cache.delete(f'wiki/page/{p.name.lower()}')
p.last_rev.text.remove_value_from_cache()
if update_meta:
Expand Down

0 comments on commit 71fb001

Please sign in to comment.