From be20fb7a52682c122b7454ee7d1c938ecf553ddd Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 27 Aug 2022 17:47:33 +0100 Subject: [PATCH] Make sentiment more usable --- core/static/chart.js | 9 +++++---- core/views/ui/drilldown.py | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/core/static/chart.js b/core/static/chart.js index df45866..54d3946 100644 --- a/core/static/chart.js +++ b/core/static/chart.js @@ -30,11 +30,12 @@ new Chart(ctx, { plugins: { tooltip: { callbacks: { - beforeFooter: function(context) { - return "Nick: " + full_data[context[0].dataIndex].nick; - }, footer: function(context) { - return "Msg: " + full_data[context[0].dataIndex].text; + var foot = "Text: " + full_data[context[0].dataIndex].text + "\n"; + foot += "Nick: " + full_data[context[0].dataIndex].nick + "\n"; + foot += "Channel: " + full_data[context[0].dataIndex].channel + "\n"; + foot += "Net: " + full_data[context[0].dataIndex].net; + return foot; } } } diff --git a/core/views/ui/drilldown.py b/core/views/ui/drilldown.py index 572451a..6997fcc 100644 --- a/core/views/ui/drilldown.py +++ b/core/views/ui/drilldown.py @@ -78,18 +78,22 @@ def make_table(context): def make_graph(results): - graph = json.dumps( - [ + graph = [] + for index, item in enumerate(results): + date = str(index) + graph.append( { - "text": item.get("msg", None) or item.get("id"), + "text": item.get("tokens", None) + or item.get("msg", None) + or item.get("id"), "nick": item.get("nick", None), + "channel": item.get("channel", None), + "net": item.get("net", None), "value": item.get("sentiment", None) or None, - "date": item.get("ts"), + "date": date, } - for item in results - ] - ) - return graph + ) + return json.dumps(graph) def drilldown_search(request, return_context=False, template=None):