From 4c743036d5611e49e504590dbadda0709ff8b8c6 Mon Sep 17 00:00:00 2001 From: Stefan Koelle Date: Tue, 11 Aug 2026 20:32:32 +0200 Subject: [PATCH] special search last updated --- src/api/main.py | 2 ++ src/api/templates/_sidebar.html | 1 + src/db.py | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/api/main.py b/src/api/main.py index 9df2f6b..83bec91 100644 --- a/src/api/main.py +++ b/src/api/main.py @@ -536,6 +536,7 @@ def web_search_special( "no_photo": db.search_contacts_without_photo, "no_city": db.search_contacts_without_city, "no_social": db.search_contacts_without_social, + "last_updated": db.search_contacts_last_updated, }.get(type) if not query_fn: @@ -545,6 +546,7 @@ def web_search_special( "no_photo": "Kontakte ohne Bild", "no_city": "Kontakte ohne Stadt", "no_social": "Kontakte ohne Social Profil", + "last_updated": "Zuletzt aktualisiert", } with db.get_connection() as conn: diff --git a/src/api/templates/_sidebar.html b/src/api/templates/_sidebar.html index cbc89a5..6ffc55d 100644 --- a/src/api/templates/_sidebar.html +++ b/src/api/templates/_sidebar.html @@ -92,5 +92,6 @@ ohne Bild ohne City ohne Social + last updated diff --git a/src/db.py b/src/db.py index 46d3a1c..7f9784b 100644 --- a/src/db.py +++ b/src/db.py @@ -232,6 +232,24 @@ def search_contacts_without_social(conn, account: str | None) -> list[dict]: return cur.fetchall() +def search_contacts_last_updated(conn, account: str | None) -> list[dict]: + where_clause, params = _account_filter_clause(account) + op = "AND" if where_clause else "WHERE" + with conn.cursor() as cur: + cur.execute( + f"""SELECT id, full_name, given_name, middle_name, family_name, + prefix, suffix, organization, birthday, account, photo_url + FROM contacts {where_clause} + {op} given_name IS NOT NULL AND given_name != '' + AND family_name IS NOT NULL AND family_name != '' + AND family_name != 'X' + ORDER BY updated_at DESC + LIMIT 200""", + params, + ) + return cur.fetchall() + + def get_most_common_birthday(conn) -> date | None: with conn.cursor() as cur: cur.execute(