diff --git a/core/lib/opensearch.py b/core/lib/opensearch.py index 3df8c27..34cc0ae 100644 --- a/core/lib/opensearch.py +++ b/core/lib/opensearch.py @@ -21,11 +21,13 @@ def initialise_opensearch(): return client -def construct_query(query, fields): +def construct_query(query, fields, results): if not fields: fields = settings.OPENSEARCH_MAIN_SEARCH_FIELDS + if not results: + results = 5 query = { - "size": 5, + "size": results, "query": { "multi_match": { "query": query, @@ -36,8 +38,8 @@ def construct_query(query, fields): return query -def run_main_query(client, query, fields=None): - search_query = construct_query(query, fields) +def run_main_query(client, query, fields=None, results=None): + search_query = construct_query(query, fields, results) # fmt: off response = client.search(body=search_query, index=settings.OPENSEARCH_INDEX_MAIN) diff --git a/core/templates/partials/product-list.html b/core/templates/partials/product-list.html index ff46ed4..b9b31a2 100644 --- a/core/templates/partials/product-list.html +++ b/core/templates/partials/product-list.html @@ -2,12 +2,8 @@ {% for plan in plans %} - {% if plan in user_plans %} -
- {% else %} -
- {% endif %} +
@@ -19,7 +15,7 @@

{{ plan.name }} £{{ plan.cost }} {% if plan in user_plans %} - + {% endif %}
{{ plan.description }} @@ -28,19 +24,19 @@

diff --git a/core/templates/ui/drilldown.html b/core/templates/ui/drilldown.html index 5e35a9c..f4278b5 100644 --- a/core/templates/ui/drilldown.html +++ b/core/templates/ui/drilldown.html @@ -1,142 +1,146 @@ {% extends "base.html" %} {% load static %} {% block content %} +
-
-
-

- {% csrf_token %} - - - - -

-
- -
-
-
-
-
- -
-
-
-
+ {% csrf_token %} +
+
+
-
-
+
+
+ + + + +
+
+
+
+ + +
+
+ +
+ +
+
+
- + + + + + + + + + + +
+
+ +
+ +
+ +
+ +
+
+
+ + + +
-
-
-
- -
-
-
- -
-
-
-
- - +
+
+ +
+
+
+ + + + +
+
+
+
+
-
-
-
- -
-
-
-
-
- + + +
+
+ +
+
+
+
+ + +
-
-
-
-
-
-
- -
-
-
-
- -
-
-
-
-
-
- - +
- - {% if results is not None %} - - - - - - - - - - - {% endif %} +
TSmsghostnickchannelnet
+ {% if results is not None %} + + + + + + + + + + + {% endif %} - - {% for item in results %} - - - - - - - - - {% endfor %} - -
TSmsghostnickchannelnet
{{ item.ts }}{{ item.msg }}{{ item.host }}{{ item.nick }}{{ item.channel }}{{ item.net }}
+ + {% for item in results %} + + {{ item.ts }} + {{ item.msg }} + {{ item.host }} + {{ item.nick }} + {{ item.channel }} + {{ item.net }} + + {% endfor %} + +
-

{{ card }} hits

+ {% if results is not None %} +

{{ card }} hits

+ {% endif %} {% endblock %} - diff --git a/core/ui/views/drilldown.py b/core/ui/views/drilldown.py index 530be1d..34123ac 100644 --- a/core/ui/views/drilldown.py +++ b/core/ui/views/drilldown.py @@ -18,20 +18,24 @@ class Drilldown(LoginRequiredMixin, View): def get(self, request): if not request.user.has_plan(self.plan_name): return render(request, "denied.html") - return render(request, self.template_name) + context = {"fields": settings.OPENSEARCH_MAIN_SEARCH_FIELDS} + return render(request, self.template_name, context) def post(self, request): if not request.user.has_plan(self.plan_name): return render(request, "denied.html") fields = None if "fields" in request.POST: - fields = request.POST["fields"] + fields = request.POST.getlist("fields") print("FIELD", fields) + if "results" in request.POST: + results = request.POST["results"] + print("RESULTS", results) if "query" in request.POST: query = request.POST["query"] # field = results.POST["field"] # print("FIELD ", field) - results = run_main_query(client, query, fields) + results = run_main_query(client, query, fields, results) pp.pprint(results) results_parsed = [] if "hits" in results.keys():