mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
forum: limit results and improve search engine speed
This commit is contained in:
parent
884855c178
commit
107c6c196f
@ -54,14 +54,10 @@ class ForumSearchView(ListView):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
query = self.request.GET.get("query", "")
|
query = self.request.GET.get("query", "")
|
||||||
queryset = SearchQuerySet().models(ForumMessage).autocomplete(auto=query)
|
queryset = SearchQuerySet().models(ForumMessage).autocomplete(auto=query)[:100]
|
||||||
excluded = [
|
return [
|
||||||
o.object.id
|
r.object for r in queryset if can_view(r.object.topic, self.request.user)
|
||||||
for o in queryset
|
][:30]
|
||||||
if not can_view(o.object.topic, self.request.user)
|
|
||||||
]
|
|
||||||
queryset.exclude(id__in=excluded)
|
|
||||||
return [r.object for r in queryset]
|
|
||||||
|
|
||||||
|
|
||||||
class ForumMainView(ListView):
|
class ForumMainView(ListView):
|
||||||
|
Loading…
Reference in New Issue
Block a user