feat: add announced checkbox to track rows

Add a persistent "announced" checkbox after each track's Announce button.
The state is stored in a new `announced` column on `show_tracks` and is
auto-set when the Announce button is pressed. The checkbox is also freely
togglable, and announced tracks have their Announce button disabled.

Also fixes .env leakage in test_config.py (pass _env_file=None) and adds
tests for the new DB method, API endpoint, and announce side-effect.

Made-with: Cursor
This commit is contained in:
cottongin
2026-04-01 22:56:43 -04:00
parent a5f77187b3
commit 11f13c86b5
7 changed files with 218 additions and 17 deletions

View File

@@ -55,6 +55,11 @@ class Database:
conn.commit()
except sqlite3.OperationalError:
pass
try:
conn.execute("ALTER TABLE show_tracks ADD COLUMN announced INTEGER NOT NULL DEFAULT 0")
conn.commit()
except sqlite3.OperationalError:
pass
conn.close()
def upsert_track(self, track: Track) -> None:
@@ -154,9 +159,9 @@ class Database:
conn = self._connect()
rows = conn.execute(
"""
SELECT st.show_id, st.track_id, st.position, t.title, t.artist,
t.permalink_url, t.artwork_url, t.duration_ms, t.license,
t.liked_at, t.raw_json
SELECT st.show_id, st.track_id, st.position, st.announced,
t.title, t.artist, t.permalink_url, t.artwork_url,
t.duration_ms, t.license, t.liked_at, t.raw_json
FROM show_tracks st
JOIN tracks t ON st.track_id = t.id
WHERE st.show_id = ?
@@ -173,9 +178,9 @@ class Database:
conn = self._connect()
row = conn.execute(
"""
SELECT st.show_id, st.track_id, st.position, t.title, t.artist,
t.permalink_url, t.artwork_url, t.duration_ms, t.license,
t.liked_at, t.raw_json
SELECT st.show_id, st.track_id, st.position, st.announced,
t.title, t.artist, t.permalink_url, t.artwork_url,
t.duration_ms, t.license, t.liked_at, t.raw_json
FROM show_tracks st
JOIN tracks t ON st.track_id = t.id
WHERE st.show_id = ? AND st.position = ?
@@ -185,6 +190,17 @@ class Database:
conn.close()
return dict(row) if row else None
def set_track_announced(
self, show_id: int, position: int, announced: bool
) -> None:
conn = self._connect()
conn.execute(
"UPDATE show_tracks SET announced = ? WHERE show_id = ? AND position = ?",
(int(announced), show_id, position),
)
conn.commit()
conn.close()
def set_show_tracks(self, show_id: int, track_ids: list[int]) -> None:
conn = self._connect()
if track_ids: