diff options
Diffstat (limited to 'Biz/PodcastItLater/Core.py')
| -rw-r--r-- | Biz/PodcastItLater/Core.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Biz/PodcastItLater/Core.py b/Biz/PodcastItLater/Core.py index 1756fc6..278b97e 100644 --- a/Biz/PodcastItLater/Core.py +++ b/Biz/PodcastItLater/Core.py @@ -128,6 +128,9 @@ class Database: # noqa: PLR0904 # Run migration to add user status field Database.migrate_add_user_status(db_path) + # Run migration to add default titles + Database.migrate_add_default_titles(db_path) + @staticmethod def add_to_queue( # noqa: PLR0913, PLR0917 url: str, @@ -589,6 +592,30 @@ class Database: # noqa: PLR0904 logger.info("Database migrated to support user status") @staticmethod + def migrate_add_default_titles(db_path: str | None = None) -> None: + """Add default titles to queue items that have None titles.""" + if db_path is None: + db_path = Database.get_default_db_path() + with Database.get_connection(db_path) as conn: + cursor = conn.cursor() + + # Update queue items with NULL titles to have a default + cursor.execute(""" + UPDATE queue + SET title = 'Untitled Article' + WHERE title IS NULL + """) + + # Get count of updated rows + updated_count = cursor.rowcount + + conn.commit() + logger.info( + "Updated %s queue items with default titles", + updated_count, + ) + + @staticmethod def create_user(email: str, db_path: str | None = None) -> tuple[int, str]: """Create a new user and return (user_id, token). |
