Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super Duper Fast Import Search 🚀 #4279

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions contentcuration/search/viewsets/contentnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
from search.utils import get_fts_search_query

from contentcuration.models import Channel
from contentcuration.models import File
from contentcuration.utils.pagination import ValuesViewsetPageNumberPagination
from contentcuration.viewsets.base import ReadOnlyValuesViewset
from contentcuration.viewsets.base import RequiredFilterSet
from contentcuration.viewsets.common import NotNullMapArrayAgg
from contentcuration.viewsets.common import UUIDFilter
from contentcuration.viewsets.common import UUIDInFilter

Expand Down Expand Up @@ -105,16 +103,8 @@ class SearchContentNodeViewSet(ReadOnlyValuesViewset):
"content_id": "contentnode__content_id",
"node_id": "contentnode__node_id",
"root_id": "channel__main_tree_id",
"title": "contentnode__title",
"description": "contentnode__description",
"author": "contentnode__author",
"provider": "contentnode__provider",
"kind": "contentnode__kind__kind",
"thumbnail_encoding": "contentnode__thumbnail_encoding",
"published": "contentnode__published",
"modified": "contentnode__modified",
"parent": "contentnode__parent_id",
"changed": "contentnode__changed",
"public": "channel__public",
}

Expand Down Expand Up @@ -148,10 +138,6 @@ def annotate_queryset(self, queryset):
"""
Annotates thumbnails, resources count and original channel name.
"""
thumbnails = File.objects.filter(
contentnode=OuterRef("contentnode__id"), preset__thumbnail=True
)

descendant_resources_count = ExpressionWrapper(((F("contentnode__rght") - F("contentnode__lft") - Value(1)) / Value(2)), output_field=IntegerField())

original_channel_name = Coalesce(
Expand All @@ -169,11 +155,6 @@ def annotate_queryset(self, queryset):

queryset = queryset.annotate(
resource_count=descendant_resources_count,
thumbnail_checksum=Subquery(thumbnails.values("checksum")[:1]),
thumbnail_extension=Subquery(
thumbnails.values("file_format__extension")[:1]
),
content_tags=NotNullMapArrayAgg("contentnode__tags__tag_name"),
original_channel_name=original_channel_name,
)

Expand Down