udata 11.0.2.dev14__py3-none-any.whl → 11.0.2.dev15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of udata might be problematic. Click here for more details.
- udata/core/topic/parsers.py +16 -1
- udata/static/chunks/{10.8ca60413647062717b1e.js → 10.471164b2a9fe15614797.js} +3 -3
- udata/static/chunks/{10.8ca60413647062717b1e.js.map → 10.471164b2a9fe15614797.js.map} +1 -1
- udata/static/chunks/{11.b6f741fcc366abfad9c4.js → 11.83535504cd650ea08f65.js} +3 -3
- udata/static/chunks/{11.b6f741fcc366abfad9c4.js.map → 11.83535504cd650ea08f65.js.map} +1 -1
- udata/static/chunks/{13.2d06442dd9a05d9777b5.js → 13.d9c1735d14038b94c17e.js} +2 -2
- udata/static/chunks/{13.2d06442dd9a05d9777b5.js.map → 13.d9c1735d14038b94c17e.js.map} +1 -1
- udata/static/chunks/{17.e8e4caaad5cb0cc0bacc.js → 17.81c57c0dedf812e43013.js} +2 -2
- udata/static/chunks/{17.e8e4caaad5cb0cc0bacc.js.map → 17.81c57c0dedf812e43013.js.map} +1 -1
- udata/static/chunks/{19.f03a102365af4315f9db.js → 19.df16abde17a42033a7f8.js} +3 -3
- udata/static/chunks/{19.f03a102365af4315f9db.js.map → 19.df16abde17a42033a7f8.js.map} +1 -1
- udata/static/chunks/{8.778091d55cd8ea39af6b.js → 8.462bb3029de008497675.js} +2 -2
- udata/static/chunks/{8.778091d55cd8ea39af6b.js.map → 8.462bb3029de008497675.js.map} +1 -1
- udata/static/chunks/{9.033d7e190ca9e226a5d0.js → 9.07515e5187f475bce828.js} +3 -3
- udata/static/chunks/{9.033d7e190ca9e226a5d0.js.map → 9.07515e5187f475bce828.js.map} +1 -1
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- udata/tests/apiv2/test_topics.py +85 -0
- {udata-11.0.2.dev14.dist-info → udata-11.0.2.dev15.dist-info}/METADATA +1 -1
- {udata-11.0.2.dev14.dist-info → udata-11.0.2.dev15.dist-info}/RECORD +24 -24
- {udata-11.0.2.dev14.dist-info → udata-11.0.2.dev15.dist-info}/WHEEL +0 -0
- {udata-11.0.2.dev14.dist-info → udata-11.0.2.dev15.dist-info}/entry_points.txt +0 -0
- {udata-11.0.2.dev14.dist-info → udata-11.0.2.dev15.dist-info}/licenses/LICENSE +0 -0
- {udata-11.0.2.dev14.dist-info → udata-11.0.2.dev15.dist-info}/top_level.txt +0 -0
udata/core/topic/parsers.py
CHANGED
|
@@ -4,6 +4,8 @@ from flask_restx.inputs import boolean
|
|
|
4
4
|
from udata.api import api
|
|
5
5
|
from udata.api.parsers import ModelApiParser
|
|
6
6
|
from udata.core.topic import DEFAULT_PAGE_SIZE
|
|
7
|
+
from udata.core.topic.models import TopicElement
|
|
8
|
+
from udata.mongo.engine import db
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
class TopicElementsParser(ModelApiParser):
|
|
@@ -71,7 +73,20 @@ class TopicApiParser(ModelApiParser):
|
|
|
71
73
|
# This allows the search_text method to tokenise with an AND
|
|
72
74
|
# between tokens whereas an OR is used without it.
|
|
73
75
|
phrase_query = " ".join([f'"{elem}"' for elem in args["q"].split(" ")])
|
|
74
|
-
|
|
76
|
+
|
|
77
|
+
# Search topics by their own content
|
|
78
|
+
topic_text_filter = db.Q(__raw__={"$text": {"$search": phrase_query}})
|
|
79
|
+
|
|
80
|
+
# Find topics that have elements matching the search
|
|
81
|
+
matching_elements = TopicElement.objects.search_text(phrase_query)
|
|
82
|
+
element_topic_ids = set(elem.topic.id for elem in matching_elements if elem.topic)
|
|
83
|
+
|
|
84
|
+
# Combine with OR
|
|
85
|
+
if element_topic_ids:
|
|
86
|
+
element_filter = db.Q(id__in=element_topic_ids)
|
|
87
|
+
topics = topics.filter(topic_text_filter | element_filter)
|
|
88
|
+
else:
|
|
89
|
+
topics = topics.filter(topic_text_filter)
|
|
75
90
|
if args.get("tag"):
|
|
76
91
|
topics = topics.filter(tags__all=args["tag"])
|
|
77
92
|
if not args.get("include_private"):
|