From 4b67b70a820e541c24b25023a30b5dceed90babe Mon Sep 17 00:00:00 2001 From: Joost Agterhoek Date: Fri, 15 Aug 2025 21:32:23 +0200 Subject: [PATCH] fixed the deduplication of the history list - set does not work because of list of objects - simple list iteration does work --- flask_soc_site/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/flask_soc_site/__init__.py b/flask_soc_site/__init__.py index 2b51f12..154f677 100644 --- a/flask_soc_site/__init__.py +++ b/flask_soc_site/__init__.py @@ -55,6 +55,7 @@ def create_app(test_config=None): ### TESTING build_history(results) + print("build_history just ran...") # session["results"] = pickle.dumps(results) # if "history" in session: # print("HISTORY IS IN SESSION") @@ -91,12 +92,23 @@ def create_app(test_config=None): return results def build_history(results): + current_history = [] if "history" in session: current_history = pickle.loads(session["history"]) + updated_history = current_history for result in results: - if result.host not in current_history: - current_history.append(result) - session["history"] = pickle.dumps(current_history) + for item in current_history: + if result.host == item.host: + print(f"{result.host} and {item.host} are the same") + else: + updated_history.append(result) + # if result not in current_history: + # current_history.append(result) + # print(f"{result} not in {current_history}") + # elif result in current_history: + # print(f"{result} is in {current_history}") + # session["history"] = pickle.dumps(current_history) + session["history"] = pickle.dumps(updated_history) elif "history" not in session: session["history"] = pickle.dumps(results)