From c6e85a7f963c7bc7fdfd1cd1cfe175f0e3998d91 Mon Sep 17 00:00:00 2001 From: WildRikku <119439592+WildRikku@users.noreply.github.com> Date: Mon, 2 Sep 2024 17:03:37 +0000 Subject: [PATCH] Use 'owner' payload from PRINT_DONE which is now available. Fixes #20 and also fixes #96. --- octoprint_printhistory/eventHandler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/octoprint_printhistory/eventHandler.py b/octoprint_printhistory/eventHandler.py index 85c3874..dae3daa 100644 --- a/octoprint_printhistory/eventHandler.py +++ b/octoprint_printhistory/eventHandler.py @@ -102,6 +102,11 @@ def eventHandler(self, event, payload): printTime = self._comm.getPrintTime() if self._comm is not None else "" currentFile["printTime"] = printTime + if "owner" in payload: + currentFile["user"] = payload["user"] + else: + currentFile["user"] = "" + # when print happened and what was the result if "history" in fileData: @@ -126,7 +131,7 @@ def eventHandler(self, event, payload): conn = sqlite3.connect(self._history_db_path) cur = conn.cursor() - cur.execute("INSERT INTO print_history (fileName, note, filamentVolume, filamentLength, printTime, success, timestamp, parameters) VALUES (:fileName, :note, :filamentVolume, :filamentLength, :printTime, :success, :timestamp, :parameters)", currentFile) + cur.execute("INSERT INTO print_history (fileName, note, filamentVolume, filamentLength, printTime, success, timestamp, user, parameters) VALUES (:fileName, :note, :filamentVolume, :filamentLength, :printTime, :success, :timestamp, :user, :parameters)", currentFile) conn.commit() conn.close()