From bcf9c117adc076d64a370a4b5e2f553622e49f44 Mon Sep 17 00:00:00 2001 From: Gosse Minnema Date: Tue, 25 Feb 2025 17:29:13 +0100 Subject: [PATCH] Check local instance results in a smarter way --- app/search/controllers.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/search/controllers.py b/app/search/controllers.py index 6ec70e7..d47af2c 100644 --- a/app/search/controllers.py +++ b/app/search/controllers.py @@ -81,14 +81,8 @@ def prepare_gui_results(query, results): sitename = app.config['SITENAME'] # results from our own instance - share_url = r['share'] - if share_url.startswith("http://"): - share_url = share_url.replace("http://", "https://", 1) - elif not share_url.startswith("https://"): - share_url = "https://" + share_url - print(f"share_url={share_url}, sitename={sitename}") - if share_url.startswith(sitename): - r['instance'] = urlparse(sitename).hostname + if r['instance'] == sitename: + r['instance'] = urlparse(sitename).hostname # make the name nicer to read r['instance_is_local'] = True r['instance_info_text'] = gettext("This result originates from the local PeARS instance.") # cross-instance results @@ -128,6 +122,8 @@ def get_search_results(query): try: print("\n Getting results on this instance") r, s = score_pages.run_search(clean_query, lang, extended=app.config['EXTEND_QUERY']) + for res in r.values(): + res["instance"] = app.config["SITENAME"] # to distinguish local results from remote ones later on results.update(r) scores.extend(s) except Exception as e: