From 39767377ebb442721ebc762cc5c194f12ff7d8da Mon Sep 17 00:00:00 2001 From: juvdiaz Date: Tue, 2 Jun 2026 22:08:13 -0600 Subject: [PATCH] Pin seeded Heimdall apps to dashboard --- apps/heimdall/web-app.yaml | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/apps/heimdall/web-app.yaml b/apps/heimdall/web-app.yaml index f9d74bf..8e1307d 100644 --- a/apps/heimdall/web-app.yaml +++ b/apps/heimdall/web-app.yaml @@ -127,6 +127,44 @@ data: (user_id,), ) + def ensure_dashboard_tag(conn, item_id, tag_id, now): + if not table_exists(conn, "item_tag"): + return + item_tag_columns = columns(conn, "item_tag") + if not {"item_id", "tag_id"}.issubset(item_tag_columns): + return + existing = conn.execute( + 'select 1 from "item_tag" where "item_id" = ? and "tag_id" = ?', + (item_id, tag_id), + ).fetchone() + if existing: + return + values = { + "item_id": item_id, + "tag_id": tag_id, + "created_at": now, + "updated_at": now, + } + insert_columns = [name for name in values if name in item_tag_columns] + placeholders = ", ".join("?" for _ in insert_columns) + quoted_insert_columns = ", ".join(quote_identifier(name) for name in insert_columns) + conn.execute( + f'insert into "item_tag" ({quoted_insert_columns}) values ({placeholders})', + [values[name] for name in insert_columns], + ) + + def home_dashboard_tag_id(conn): + item_columns = columns(conn, "items") + if not {"id", "title"}.issubset(item_columns): + return 0 + row = conn.execute( + 'select "id" from "items" where "title" = ? order by "id" limit 1', + ("app.dashboard",), + ).fetchone() + if row: + return row[0] + return 0 + def wait_for_items_table(db_path): while True: try: @@ -141,6 +179,7 @@ data: def upsert_links(conn, links): item_columns = columns(conn, "items") seed_user_id = 1 + home_dashboard_tag = home_dashboard_tag_id(conn) now = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S") ensure_public_dashboard(conn, seed_user_id) @@ -176,6 +215,7 @@ data: params = [values[name] for name in update_columns] params.append(existing[0]) conn.execute(f'update "items" set {assignments} where "id" = ?', params) + ensure_dashboard_tag(conn, existing[0], home_dashboard_tag, now) continue insert_columns = [ @@ -188,6 +228,8 @@ data: f'insert into "items" ({quoted_insert_columns}) values ({placeholders})', [values[name] for name in insert_columns], ) + new_item_id = conn.execute("select last_insert_rowid()").fetchone()[0] + ensure_dashboard_tag(conn, new_item_id, home_dashboard_tag, now) conn.commit()