last sync with changes on dashboard

This commit is contained in:
2026-08-05 15:20:05 +02:00
parent 12e36b2f17
commit 4f27cc596e
2 changed files with 21 additions and 0 deletions
+16
View File
@@ -195,10 +195,25 @@ def web_dashboard(
) )
last_sync = cur.fetchone() last_sync = cur.fetchone()
change_filter = "AND account = %s" if account_name else ""
change_params = [account_name] if account_name else []
cur.execute(
f"""SELECT started_at, contacts_upserted
FROM sync_runs
WHERE contacts_upserted > 0 {change_filter}
ORDER BY started_at DESC
LIMIT 1""",
change_params,
)
last_sync_with_changes = cur.fetchone()
if last_sync: if last_sync:
last_sync["started_at"] = str(last_sync["started_at"]) last_sync["started_at"] = str(last_sync["started_at"])
last_sync["finished_at"] = str(last_sync["finished_at"]) if last_sync["finished_at"] else None last_sync["finished_at"] = str(last_sync["finished_at"]) if last_sync["finished_at"] else None
if last_sync_with_changes:
last_sync_with_changes["started_at"] = str(last_sync_with_changes["started_at"])
return templates.TemplateResponse( return templates.TemplateResponse(
"dashboard.html", "dashboard.html",
{ {
@@ -209,6 +224,7 @@ def web_dashboard(
"contact_count": contact_count, "contact_count": contact_count,
"upcoming_birthdays": upcoming_birthdays, "upcoming_birthdays": upcoming_birthdays,
"last_sync": last_sync, "last_sync": last_sync,
"last_sync_with_changes": last_sync_with_changes,
"current_year": date.today().year, "current_year": date.today().year,
}, },
) )
+5
View File
@@ -252,6 +252,11 @@
· {{ last_sync.contacts_deleted }} gelöscht · {{ last_sync.contacts_deleted }} gelöscht
{% endif %} {% endif %}
</div> </div>
{% if last_sync_with_changes %}
<div class="sync-detail">
{{ last_sync_with_changes.started_at }} · {{ last_sync_with_changes.contacts_upserted }} aktualisiert
</div>
{% endif %}
{% if last_sync.error_message %} {% if last_sync.error_message %}
<div class="sync-detail" style="color: #dc3545; margin-top: 0.5rem;"> <div class="sync-detail" style="color: #dc3545; margin-top: 0.5rem;">
{{ last_sync.error_message }} {{ last_sync.error_message }}