Remove some debug statements

This commit is contained in:
Mark Veidemanis 2022-08-10 20:36:55 +01:00
parent d36f397c6e
commit aaca3a8469
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 3 additions and 30 deletions

View File

@ -180,8 +180,6 @@ def query_results(request, query_params, size=None):
): ):
from_ts = f"{query_params['from_date']}T{query_params['from_time']}Z" from_ts = f"{query_params['from_date']}T{query_params['from_time']}Z"
to_ts = f"{query_params['to_date']}T{query_params['to_time']}Z" to_ts = f"{query_params['to_date']}T{query_params['to_time']}Z"
print("from ts", from_ts)
print("to_ts", to_ts)
range_query = { range_query = {
"range": { "range": {
"ts": { "ts": {

View File

@ -85,16 +85,12 @@ def drilldown_search(request, return_context=False, template=None):
sizes = settings.OPENSEARCH_MAIN_SIZES sizes = settings.OPENSEARCH_MAIN_SIZES
if request.GET: if request.GET:
print("GET")
if not request.htmx: if not request.htmx:
print("NOT REQUEST HTMX")
template_name = "ui/drilldown/drilldown.html" template_name = "ui/drilldown/drilldown.html"
query_params = request.GET.dict() query_params = request.GET.dict()
elif request.POST: elif request.POST:
print("POST")
query_params = request.POST.dict() query_params = request.POST.dict()
else: else:
print("ELSE")
template_name = "ui/drilldown/drilldown.html" template_name = "ui/drilldown/drilldown.html"
context = {"sizes": sizes} context = {"sizes": sizes}
return render(request, template_name, context) return render(request, template_name, context)
@ -115,7 +111,6 @@ def drilldown_search(request, return_context=False, template=None):
context = query_results(request, query_params) context = query_results(request, query_params)
elif request.POST: elif request.POST:
context = query_results(request, query_params) context = query_results(request, query_params)
print("QUERY PARAMS", query_params)
# Turn the query into tags for populating the taglist # Turn the query into tags for populating the taglist
if "query" in query_params: if "query" in query_params:
@ -124,13 +119,11 @@ def drilldown_search(request, return_context=False, template=None):
context["params"] = query_params context["params"] = query_params
if "message" in context: if "message" in context:
print("MESSAGE IN CONTEXT")
return render(request, template_name, context) return render(request, template_name, context)
# Create data for chart.js sentiment graph # Create data for chart.js sentiment graph
graph = make_graph(context["object_list"]) graph = make_graph(context["object_list"])
context["data"] = graph context["data"] = graph
print("MADE GRAPH")
if context: if context:
context["sizes"] = sizes context["sizes"] = sizes
@ -150,19 +143,14 @@ def drilldown_search(request, return_context=False, template=None):
response = render(request, template_name, context) response = render(request, template_name, context)
if request.GET: if request.GET:
print("IS GET")
if request.htmx: if request.htmx:
print("IS HTMX PUSHING", url_params)
response["HX-Push"] = reverse("home") + "?" + url_params response["HX-Push"] = reverse("home") + "?" + url_params
elif request.POST: elif request.POST:
print("IS POST")
print("TEMPLATE", template_name)
response["HX-Push"] = reverse("home") + "?" + url_params response["HX-Push"] = reverse("home") + "?" + url_params
if return_context: if return_context:
return context return context
return response return response
else: else:
print("NO RESULTS", context)
return HttpResponse("No results") return HttpResponse("No results")
@ -172,18 +160,13 @@ class DrilldownTableView(SingleTableView):
paginate_by = 5 paginate_by = 5
def get_queryset(self, request, **kwargs): def get_queryset(self, request, **kwargs):
print("QUERYSET KWARGS", kwargs)
context = drilldown_search(request, return_context=True) context = drilldown_search(request, return_context=True)
# Save the context as we will need to merge other attributes later # Save the context as we will need to merge other attributes later
self.context = context self.context = context
print(
"VIEW CONTEXT",
{k: v for k, v in context.items() if k not in ["object_list", "data"]},
)
if "object_list" in context: if "object_list" in context:
return context["object_list"] return context["object_list"]
else: else:
print("NO OBJ LIST IN CONTEXT", context)
return [] return []
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
@ -203,25 +186,17 @@ class DrilldownTableView(SingleTableView):
context = self.get_context_data() context = self.get_context_data()
if isinstance(self.context, HttpResponse): if isinstance(self.context, HttpResponse):
return self.context return self.context
print(
"TABLE CONTEXT",
{k: v for k, v in context.items() if k not in ["object_list", "data"]},
)
for k, v in self.context.items(): for k, v in self.context.items():
if k not in context: if k not in context:
context[k] = v context[k] = v
print(
"FINAL CONTEXT",
{k: v for k, v in context.items() if k not in ["object_list", "data"]},
)
if request.method == "GET": if request.method == "GET":
if not request.htmx: if not request.htmx:
print("NOT REQUEST HTMX")
self.template_name = "ui/drilldown/drilldown.html" self.template_name = "ui/drilldown/drilldown.html"
response = self.render_to_response(context) response = self.render_to_response(context)
# if not request.method == "GET": # if not request.method == "GET":
if "client_uri" in context: if "client_uri" in context:
print("PUSHING CLIENT URI", context["client_uri"])
response["HX-Push"] = reverse("home") + "?" + context["client_uri"] response["HX-Push"] = reverse("home") + "?" + context["client_uri"]
return response return response