From 159a0bd0a1322674a8fe58e83165a9d406bf46d1 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Fri, 29 Jul 2022 22:22:22 +0100 Subject: [PATCH] Fix result annotation for when certain fields do not exist --- core/lib/opensearch.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/lib/opensearch.py b/core/lib/opensearch.py index ec37647..86bc2be 100644 --- a/core/lib/opensearch.py +++ b/core/lib/opensearch.py @@ -56,12 +56,15 @@ def annotate_results(results_parsed): net, [x["nick"] for x in results_parsed if x["src"] == "irc"] ) for item in results_parsed: - if item["nick"] in online_info: - item["online"] = online_info[item["nick"]] - if item["channel"] in num_users: - item["num_users"] = num_users[item["channel"]] - if item["nick"] in num_chans: - item["num_chans"] = num_chans[item["nick"]] + if "nick" in item: + 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 "nick" in item: + if item["nick"] in num_chans: + item["num_chans"] = num_chans[item["nick"]] def filter_blacklisted(user, response):