summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-09-04 14:07:47 -0400
committerBen Sima (aider) <ben@bsima.me>2025-09-04 14:07:47 -0400
commit2a2ff0749f18670ab82c304c8c3468aeea47846f (patch)
tree454162be04e52c66af9ed036ad90cfa836f35c66
parent3d379840141399eaa9c44f72e0ac48266a3edf40 (diff)
Add Default Titles for Queue Items
Implement a migration to add default titles to queue items with NULL titles. This ensures that every queue item has a meaningful title, improving user experience and data consistency. The migration updates items with 'Untitled Article' when no title is present.
-rw-r--r--Biz/PodcastItLater/Core.py27
-rw-r--r--Biz/PodcastItLater/Web.py33
2 files changed, 55 insertions, 5 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).
diff --git a/Biz/PodcastItLater/Web.py b/Biz/PodcastItLater/Web.py
index 3a6d06c..6770d33 100644
--- a/Biz/PodcastItLater/Web.py
+++ b/Biz/PodcastItLater/Web.py
@@ -869,9 +869,11 @@ class AdminView(Component[AnyChildren, AdminViewAttrs]):
),
html.td(
html.div(
- item.get(
- "title",
- "-",
+ (
+ item.get(
+ "title",
+ )
+ or "-"
)[
:TITLE_TRUNCATE_LENGTH
]
@@ -1851,8 +1853,29 @@ def admin_queue_status(request: Request) -> AdminView | Response | html.div:
),
title=item["url"],
style={
- "max-width": ("300px"),
- "overflow": ("hidden"),
+ "max-width": "300px",
+ "overflow": "hidden",
+ "text-overflow": "ellipsis",
+ },
+ ),
+ style={"padding": "10px"},
+ ),
+ html.td(
+ html.div(
+ (item.get("title") or "-")[
+ :TITLE_TRUNCATE_LENGTH
+ ]
+ + (
+ "..."
+ if item.get("title")
+ and len(item["title"])
+ > TITLE_TRUNCATE_LENGTH
+ else ""
+ ),
+ title=item.get("title", ""),
+ style={
+ "max-width": "200px",
+ "overflow": "hidden",
"text-overflow": "ellipsis",
},
),