Skip to content

Commit 37efc0f

Browse files
Merge pull request #89 from allenhutchison/fix/remove-subscribed-only-parameter
fix: remove obsolete subscribed_only parameter from list_podcasts calls
2 parents 0eca428 + 778aa30 commit 37efc0f

File tree

6 files changed

+30
-54
lines changed

6 files changed

+30
-54
lines changed

scripts/backfill_last_new_episode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def backfill_last_new_episode():
2424
print("Backfilling last_new_episode for podcasts...")
2525

2626
# Get all podcasts using public API
27-
podcasts = repo.list_podcasts(subscribed_only=False)
27+
podcasts = repo.list_podcasts()
2828

2929
updated_count = 0
3030
skipped_count = 0

scripts/export_sqlite_to_sql.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ def export_table_data(cursor, table_name, output_file):
5353
table_name: Name of table to export
5454
output_file: File object to write INSERT statements to
5555
"""
56+
# Columns to exclude (removed from schema)
57+
excluded_columns = {'is_subscribed'}
58+
5659
# Boolean columns (SQLite stores as INTEGER 0/1, PostgreSQL needs true/false)
5760
# These are known boolean columns in our schema
5861
boolean_columns = {
59-
'is_subscribed', 'itunes_explicit', 'is_active', 'is_admin',
62+
'itunes_explicit', 'is_active', 'is_admin',
6063
'email_digest_enabled', 'smtp_use_tls'
6164
}
6265

@@ -73,16 +76,19 @@ def export_table_data(cursor, table_name, output_file):
7376
output_file.write(f"-- No data in {table_name}\n")
7477
return
7578

76-
# Get column names from cursor description
77-
columns = [desc[0] for desc in cursor.description]
79+
# Get column names from cursor description, excluding removed columns
80+
all_columns = [desc[0] for desc in cursor.description]
81+
columns = [col for col in all_columns if col not in excluded_columns]
82+
keep_indices = [i for i, col in enumerate(all_columns) if col not in excluded_columns]
7883
col_list = ", ".join(columns)
7984

8085
output_file.write(f"-- Inserting {len(rows)} rows into {table_name}\n")
8186

8287
for row in rows:
8388
values = []
84-
for idx, val in enumerate(row):
85-
col_name = columns[idx]
89+
for idx in keep_indices:
90+
col_name = all_columns[idx]
91+
val = row[idx]
8692
# Handle JSON columns - keep as-is, just wrap in single quotes
8793
if col_name in json_columns:
8894
if val is None:

scripts/migrate_sqlite_to_postgres.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,25 @@ def migrate_podcasts(sqlite_conn, pg_conn, dry_run=False):
5959
"""Migrate podcasts table."""
6060
sqlite_cur = sqlite_conn.cursor()
6161
sqlite_cur.execute("SELECT * FROM podcasts")
62-
columns = [description[0] for description in sqlite_cur.description]
62+
all_columns = [description[0] for description in sqlite_cur.description]
6363
rows = sqlite_cur.fetchall()
6464

6565
logger.info(f"Found {len(rows)} podcasts to migrate")
6666

6767
if dry_run or not rows:
6868
return len(rows)
6969

70+
# Columns to exclude (removed from schema)
71+
excluded_columns = {'is_subscribed'}
72+
73+
# Filter columns and get indices to keep
74+
columns = []
75+
keep_indices = []
76+
for i, col in enumerate(all_columns):
77+
if col not in excluded_columns:
78+
columns.append(col)
79+
keep_indices.append(i)
80+
7081
pg_cur = pg_conn.cursor()
7182

7283
# Build INSERT statement
@@ -75,11 +86,12 @@ def migrate_podcasts(sqlite_conn, pg_conn, dry_run=False):
7586
insert_sql = f'INSERT INTO podcasts ({columns_str}) VALUES ({placeholders}) ON CONFLICT (id) DO NOTHING'
7687

7788
for row in rows:
78-
# Convert SQLite booleans (0/1) to Python booleans
89+
# Convert SQLite booleans (0/1) to Python booleans, excluding removed columns
7990
converted_row = []
80-
for i, val in enumerate(row):
81-
col_name = columns[i]
82-
if col_name in ('is_subscribed', 'itunes_explicit') and val is not None:
91+
for i in keep_indices:
92+
col_name = all_columns[i]
93+
val = row[i]
94+
if col_name == 'itunes_explicit' and val is not None:
8395
converted_row.append(bool(val))
8496
else:
8597
converted_row.append(val)

src/db/repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ def get_podcast_stats(self, podcast_id: str) -> dict[str, Any]:
814814
815815
Returns:
816816
stats (Dict[str, Any]): A dictionary containing per-podcast statistics and counts, typically including:
817-
- podcast (dict): A short snapshot of the podcast (e.g., `id`, `title`, `feed_url`, `is_subscribed`).
817+
- podcast (dict): A short snapshot of the podcast (e.g., `id`, `title`, `feed_url`).
818818
- total_episodes (int): Total number of episodes for the podcast.
819819
- by_download_status (dict): Counts keyed by download status (e.g., `pending`, `in_progress`, `completed`, `failed`).
820820
- by_transcript_status (dict): Counts keyed by transcript status (e.g., `pending`, `in_progress`, `completed`, `failed`).

src/web/app.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,6 @@ async def list_all_podcasts(
689689
user_id = current_user["sub"]
690690
all_podcasts = await asyncio.to_thread(
691691
_repository.list_podcasts,
692-
subscribed_only=False,
693692
sort_by=sort_by,
694693
sort_order=sort_order
695694
)

tests/test_web_app.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -347,47 +347,6 @@ def test_generate_agentic_response_is_async(self):
347347
assert inspect.isasyncgenfunction(generate_agentic_response)
348348

349349

350-
class TestChatEndpointWithSubscribedOnly:
351-
"""Tests for chat endpoint with subscribed_only parameter."""
352-
353-
def test_chat_endpoint_accepts_subscribed_only_in_request(self, client):
354-
"""Test that chat endpoint accepts subscribed_only in request body."""
355-
# Note: Will return 401 without auth, but validates request structure
356-
response = client.post(
357-
"/api/chat",
358-
json={
359-
"query": "What are the latest episodes?",
360-
"subscribed_only": True
361-
}
362-
)
363-
# Should fail auth, not request validation
364-
assert response.status_code == 401
365-
366-
def test_chat_endpoint_accepts_subscribed_only_false(self, client):
367-
"""Test that chat endpoint accepts subscribed_only=False."""
368-
response = client.post(
369-
"/api/chat",
370-
json={
371-
"query": "Search all podcasts",
372-
"subscribed_only": False
373-
}
374-
)
375-
assert response.status_code == 401 # Auth failure, not validation
376-
377-
def test_chat_endpoint_validates_request_with_all_filters(self, client):
378-
"""Test that chat endpoint accepts multiple filter parameters."""
379-
response = client.post(
380-
"/api/chat",
381-
json={
382-
"query": "Test query",
383-
"podcast_id": "123e4567-e89b-12d3-a456-426614174000",
384-
"subscribed_only": True
385-
}
386-
)
387-
# Should fail auth before processing filters
388-
assert response.status_code == 401
389-
390-
391350
class TestValidatePodcastId:
392351
"""Tests for _validate_podcast_id function."""
393352

0 commit comments

Comments
 (0)