Skip to content

Commit

Permalink
search: Disable promoted results, as it's broken in recent wagtail
Browse files Browse the repository at this point in the history
(and there's currently none in the datbase)
  • Loading branch information
Bjwebb committed Sep 11, 2024
1 parent b00317c commit b2d5df7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions search/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from itertools import chain
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import render
from wagtail.models import Page
Expand Down Expand Up @@ -67,14 +66,19 @@ def serve(self, request, page=None):
for r in m.objects.live().public().search(search_query).annotate_score('_score')]
search_results = sorted(search_results, key=lambda x: x._score, reverse=True)

promoted = [x.page.specific for x in Query.get(search_query).editors_picks.all() if x.page.live]
promoted_page_ids = [promoted_page.id for promoted_page in promoted]
filtered_search_results = [result for result in search_results if result.id not in promoted_page_ids]
# These don't work with recent wagtail,
# but there's currently no editors picks in the database,
# so disable for now.
# promoted = [x.page.specific for x in Query.get(search_query).editors_picks.all() if x.page.live]
# promoted_page_ids = [promoted_page.id for promoted_page in promoted]
# filtered_search_results = [result for result in search_results if result.id not in promoted_page_ids]

query = Query.get(search_query)
query.add_hit()

results = list(chain(promoted, filtered_search_results))
# Disabled, see above
# results = list(chain(promoted, filtered_search_results))
results = search_results

else:
results = Page.objects.none()
Expand Down

0 comments on commit b2d5df7

Please sign in to comment.