From 60dfd3434ab7dbbf546b527817f2837a766b9322 Mon Sep 17 00:00:00 2001 From: Shawn Date: Fri, 22 May 2026 18:25:54 -0400 Subject: [PATCH] feat: add Disney/Non-Disney quick filter to dropdown panel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend: - disney_filter query param on /api/assets (values: 'disney' | 'non_disney') - Detects Disney by checking disney_park IS NOT NULL OR customer name LIKE 'D-%' - Catches ESPN, Wide World of Sports, all Disney resorts, etc. - Adds LEFT JOIN to customers table when disney_filter is active Frontend: - '🏰 Disney only' and '🏢 Non-Disney' options in Disney Park dropdown - Active filter tag shows which is selected - Works together with other dropdown filters --- server.py | 12 ++++++++++-- static/index.html | 28 +++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index 00f6e34..75915bc 100644 --- a/server.py +++ b/server.py @@ -988,6 +988,7 @@ def list_assets( location_id: Optional[int] = Query(None), assigned_to: Optional[int] = Query(None), disney_park: Optional[str] = Query(None), + disney_filter: Optional[str] = Query(None), q: Optional[str] = Query(None), limit: int = Query(100, ge=1, le=2000), offset: int = Query(0, ge=0), @@ -1008,6 +1009,10 @@ def list_assets( if disney_park: conditions.append("disney_park = ?") params.append(disney_park) + if disney_filter == "disney": + conditions.append("(disney_park IS NOT NULL OR c.name LIKE 'D-%')") + elif disney_filter == "non_disney": + conditions.append("(disney_park IS NULL AND (c.name IS NULL OR c.name NOT LIKE 'D-%'))") if model: conditions.append("model = ?") params.append(model) @@ -1026,7 +1031,10 @@ def list_assets( params.extend([like, like, like, like]) where = " AND ".join(conditions) - sql = "SELECT * FROM assets" + join_clause = "" + if disney_filter: + join_clause = " LEFT JOIN customers c ON assets.customer_id = c.id" + sql = f"SELECT assets.* FROM assets{join_clause}" if where: sql += f" WHERE {where}" sql += " ORDER BY created_at DESC LIMIT ? OFFSET ?" @@ -1034,7 +1042,7 @@ def list_assets( rows = conn.execute(sql, params).fetchall() # Get total count for pagination - count_sql = "SELECT COUNT(*) FROM assets" + count_sql = f"SELECT COUNT(*) FROM assets{join_clause}" if where: count_sql += f" WHERE {where}" total = conn.execute(count_sql, params[:len(params)-2]).fetchone()[0] diff --git a/static/index.html b/static/index.html index a667318..b32c1e3 100644 --- a/static/index.html +++ b/static/index.html @@ -1134,6 +1134,9 @@
Disney Park