From f35eb51aafba0942d4084f292a3c431372b0102a Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Mon, 5 Sep 2022 07:20:30 +0100 Subject: [PATCH] Update internal index name --- app/local_settings.example.py | 2 +- core/lib/context.py | 2 +- core/lib/manticore.py | 11 +++++++++-- core/lib/opensearch.py | 2 +- .../manage/threshold/irc/network/relays.html | 4 ++-- core/templates/ui/drilldown/search_partial.html | 6 +++--- core/views/ui/drilldown.py | 2 +- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/local_settings.example.py b/app/local_settings.example.py index d9b46b6..cbf04b9 100644 --- a/app/local_settings.example.py +++ b/app/local_settings.example.py @@ -18,7 +18,7 @@ OPENSEARCH_SOURCES_RESTRICTED = ["irc"] MANTICORE_URL = "http://monolith-db-1:9308" MANTICORE_INDEX_MAIN = "main" MANTICORE_INDEX_META = "meta" -MANTICORE_INDEX_INT = "int" +MANTICORE_INDEX_INT = "internal" MANTICORE_MAIN_SIZES = ["20", "50", "100", "200", "400", "800"] MANTICORE_MAIN_SIZES_ANON = ["20", "50", "100"] diff --git a/core/lib/context.py b/core/lib/context.py index ccff818..dcb242e 100644 --- a/core/lib/context.py +++ b/core/lib/context.py @@ -25,7 +25,7 @@ def construct_query(index, net, channel, src, num, size, type=None, nicks=None): "src", "tokens", ] - if index == "int": + if index == "internal": fields.append("mtype") if channel == "*status" or type == "znc": if {"match": {"channel": channel}} in extra_must: diff --git a/core/lib/manticore.py b/core/lib/manticore.py index df264c5..fbe9a95 100644 --- a/core/lib/manticore.py +++ b/core/lib/manticore.py @@ -84,7 +84,12 @@ def run_query(client, user, search_query): response["cache"] = True return response response = client.search(search_query) + print("PRERESP", response) response = response.to_dict() + print("RESP", response) + if "took" in response: + if response["took"] is None: + return None filter_blacklisted(user, response) # Write cache @@ -147,7 +152,7 @@ def query_results( } if index == "meta": index = settings.MANTICORE_INDEX_META - elif index == "int": + elif index == "internal": index = settings.MANTICORE_INDEX_INT else: message = "Index is not valid." @@ -317,7 +322,9 @@ def query_results( search_query, ) if not results: - return False + message = "Error running query" + message_class = "danger" + return {"message": message, "class": message_class} # results = results.to_dict() results_parsed = parse_results(results) if annotate: diff --git a/core/lib/opensearch.py b/core/lib/opensearch.py index 032cb1a..ec8fd44 100644 --- a/core/lib/opensearch.py +++ b/core/lib/opensearch.py @@ -383,7 +383,7 @@ def query_results( } if index == "meta": index = settings.OPENSEARCH_INDEX_META - elif index == "int": + elif index == "internal": index = settings.OPENSEARCH_INDEX_INT else: message = "Index is not valid." diff --git a/core/templates/manage/threshold/irc/network/relays.html b/core/templates/manage/threshold/irc/network/relays.html index 85eeba6..13205d2 100644 --- a/core/templates/manage/threshold/irc/network/relays.html +++ b/core/templates/manage/threshold/irc/network/relays.html @@ -106,7 +106,7 @@ "channel": "*status", "time": "None", "date": "None", - "index": "int", + "index": "internal", "type": "znc", "mtype": "None", "nick": "*status", @@ -196,7 +196,7 @@ "channel": "{{ sinst.entity }}", "time": "None", "date": "None", - "index": "int", + "index": "internal", "type": "auth", "mtype": "None", "nick": "{{ sinst.entity }}", diff --git a/core/templates/ui/drilldown/search_partial.html b/core/templates/ui/drilldown/search_partial.html index 57fef21..7b2f1a3 100644 --- a/core/templates/ui/drilldown/search_partial.html +++ b/core/templates/ui/drilldown/search_partial.html @@ -354,10 +354,10 @@ {% endif %} - {% if params.index == 'int' %} - + {% if params.index == 'internal' %} + {% else %} - + {% endif %} {% if params.index == 'meta' %} diff --git a/core/views/ui/drilldown.py b/core/views/ui/drilldown.py index aaf6f04..efa575b 100644 --- a/core/views/ui/drilldown.py +++ b/core/views/ui/drilldown.py @@ -338,7 +338,7 @@ class DrilldownContextModal(APIView): query = True if ( - query_params["index"] == "int" + query_params["index"] == "internal" and query_params["mtype"] == "msg" and not type == "query" ):