From 53cb9a7f76c5f1db9ce00e5ea5f0cb77962cc78c Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 1 Feb 2023 07:20:31 +0000 Subject: [PATCH] When annotating results, don't send empty queries to Threshold --- core/db/processing.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/core/db/processing.py b/core/db/processing.py index 0f41a7b..c7667a0 100644 --- a/core/db/processing.py +++ b/core/db/processing.py @@ -39,23 +39,32 @@ def annotate_results(results): ] ) ) - online_info = annotate_online(net, nicks) + online_info = None + num_users = None + num_chans = None + if nicks: + online_info = annotate_online(net, nicks) # Annotate the number of users in the channel - num_users = annotate_num_users(net, channels) + if channels: + num_users = annotate_num_users(net, channels) # Annotate the number channels the user is on - num_chans = annotate_num_chans(net, nicks) + if nicks: + num_chans = annotate_num_chans(net, nicks) for item in results: if "net" in item: if item["net"] == net: if "nick" in item: - if item["nick"] in online_info: - item["online"] = online_info[item["nick"]] + if online_info: + if item["nick"] in online_info: + item["online"] = online_info[item["nick"]] if "channel" in item: - if item["channel"] in num_users: - item["num_users"] = num_users[item["channel"]] + if num_users: + if item["channel"] in num_users: + item["num_users"] = num_users[item["channel"]] if "nick" in item: - if item["nick"] in num_chans: - item["num_chans"] = num_chans[item["nick"]] + if num_chans: + if item["nick"] in num_chans: + item["num_chans"] = num_chans[item["nick"]] def parse_results(results, meta=None):