fixed the deduplication of the history list - set does not work because of list of objects - simple list iteration does work
This commit is contained in:
parent
3502bf4d16
commit
4b67b70a82
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user