Pin seeded Heimdall apps to dashboard
Homelab Main / deploy (push) Successful in 1m22s
Details
Homelab Main / deploy (push) Successful in 1m22s
Details
This commit is contained in:
parent
122407899d
commit
39767377eb
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue