Skip to content

Commit

Permalink
Add the time of the last change
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 26, 2023
1 parent faa0800 commit 9c22526
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scan_to_paperless/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@ def __init__(self, no_write: bool = False) -> None:
self._file = os.path.join(os.environ.get("SCAN_SOURCE_FOLDER", "/source"), "status.html")
self._status: Dict[str, _Folder] = {}
self._global_status = "Starting..."
self._global_status_update = datetime.datetime.utcnow().replace(microsecond=0)
self._start_time = datetime.datetime.utcnow().replace(microsecond=0)
self._last_scan = datetime.datetime.utcnow()
self.scan()

def set_global_status(self, status: str) -> None:
"""Set the global status."""

if self._global_status == status:
return

self._global_status = status
self._global_status_update = datetime.datetime.utcnow().replace(microsecond=0)

self.write()

def set_status(self, name: str, status: str, details: str = "") -> None:
Expand Down Expand Up @@ -160,7 +166,9 @@ def write(self) -> None:
</head>
<body class="px-5 py-4">
<h1>Scan to Paperless status</h1>
<p>{self._global_status}</p>
<p>{self._global_status} since <script>
window.document.write(new Date('{self._global_status_update.isoformat()}Z').toLocaleString());
</script></p>
<p>Started at: <script>
window.document.write(new Date('{self._start_time.isoformat()}Z').toLocaleString());
</script></p>
Expand Down

0 comments on commit 9c22526

Please # to comment.