diff --git a/tapiriik/web/templates/diag/dashboard.html b/tapiriik/web/templates/diag/dashboard.html
index d97ee7a43..9ab2f02c8 100644
--- a/tapiriik/web/templates/diag/dashboard.html
+++ b/tapiriik/web/templates/diag/dashboard.html
@@ -68,7 +68,7 @@
Sync
{{ userId|slice:":7" }} |
{{ userId }} |
{{ lockedUser.SynchronizationProgress|percentage }} |
- {% if lockedUser.SynchronizationWorker not in allWorkerPIDs %} (orphaned){% endif %}{% if lockedUser.SynchronizationWorker in stalledWorkerPIDs %} (stalled){% endif %} |
+ {% if lockedUser.SynchronizationWorker not in allWorkerPIDs and lockedUser.SynchronizationWorker not in allWorkerPIDsPre %} (orphaned){% endif %}{% if lockedUser.SynchronizationWorker in stalledWorkerPIDs %} (stalled){% endif %} |
{% endwith %}
{% endfor %}
diff --git a/tapiriik/web/views/diagnostics.py b/tapiriik/web/views/diagnostics.py
index 6c5e07845..2fe1e7a1c 100644
--- a/tapiriik/web/views/diagnostics.py
+++ b/tapiriik/web/views/diagnostics.py
@@ -22,6 +22,9 @@ def diag_dashboard(req):
stall_timeout = timedelta(minutes=1)
+ # We fetch this twice so the (orphaned) indicators are correct even if there were writes during all these other queries
+ context["allWorkerPIDsPre"] = [x["Process"] for x in db.sync_workers.find()]
+
context["lockedSyncUsers"] = list(db.users.find({"SynchronizationWorker": {"$ne": None}}))
context["lockedSyncRecords"] = len(context["lockedSyncUsers"])