Implement a history-based matching algorythm

The bot will attempt to keep producing groups with entirely unique matches based on the full history of matches until it can't. It'll then step forward and ignore a week of history and try again, ignoring more history until no history is left
This commit is contained in:
Marc Di Luzio 2024-08-10 15:12:14 +01:00
parent ed2375386b
commit 874a24dd1d
8 changed files with 388 additions and 104 deletions

View file

@ -1,5 +1,6 @@
"""File operation helpers"""
import json
import shutil
def load(file: str) -> dict:
@ -9,6 +10,11 @@ def load(file: str) -> dict:
def save(file: str, content: dict):
"""Save out a content dictionary to a file"""
with open(file, "w") as f:
"""
Save out a content dictionary to a file
Stores it in an intermediary file first incase the dump fails
"""
intermediate = file + ".nxt"
with open(intermediate, "w") as f:
json.dump(content, f, indent=4)
shutil.move(intermediate, file)