From 22fe83b8b00ced8de93db57c81ecc71310190a96 Mon Sep 17 00:00:00 2001 From: nstarikov Date: Tue, 11 Aug 2026 21:08:21 +0300 Subject: [PATCH] docs: plan RSS title deduplication --- .../2026-08-11-rss-title-deduplication.md | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 dzen-assistant/docs/superpowers/plans/2026-08-11-rss-title-deduplication.md diff --git a/dzen-assistant/docs/superpowers/plans/2026-08-11-rss-title-deduplication.md b/dzen-assistant/docs/superpowers/plans/2026-08-11-rss-title-deduplication.md new file mode 100644 index 0000000..9dad5a2 --- /dev/null +++ b/dzen-assistant/docs/superpowers/plans/2026-08-11-rss-title-deduplication.md @@ -0,0 +1,130 @@ +# RSS Title Deduplication Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Keep each Dzen article title in the RSS `` metadata while removing the feed-generated duplicate `<h1>` from `content:encoded`. + +**Architecture:** Keep the existing `render_article_html(..., rss_safe=True)` pipeline as the sole producer of the RSS article body. Add one focused integration-style unit test using an in-memory SQLite database to exercise the real feed query and inspect the generated XML. + +**Tech Stack:** Python 3, SQLAlchemy, `unittest`, `xml.etree.ElementTree` + +--- + +### Task 1: Remove the generated RSS body heading + +**Files:** +- Create: `tests/test_rss.py` +- Modify: `app/rss.py:204` + +- [ ] **Step 1: Write the failing regression test** + +Create `tests/test_rss.py`: + +```python +import unittest +from datetime import datetime, timedelta, timezone +from xml.etree import ElementTree + +from sqlalchemy import create_engine +from sqlalchemy.orm import Session + +from app.config import Settings +from app.database import Base +from app.models import Article +from app.rss import build_feed_xml + + +class RssFeedTest(unittest.TestCase): + def test_article_title_is_metadata_only_not_generated_body_heading(self): + engine = create_engine("sqlite:///:memory:") + Base.metadata.create_all(engine) + article = Article( + slug="test-article", + title="Тестовый заголовок", + lead="<p>Тестовый лид.</p>", + body_html="<p>Основной текст.</p>", + cta_html="", + feature_image_url="", + status="published", + rss_guid="test-guid", + published_at=datetime.now(timezone.utc) - timedelta(minutes=1), + ) + + with Session(engine) as session: + session.add(article) + session.commit() + xml = build_feed_xml(session, Settings(public_base_url="https://example.test")) + + root = ElementTree.fromstring(xml) + item = root.find("./channel/item") + self.assertIsNotNone(item) + self.assertEqual(item.findtext("title"), "Тестовый заголовок") + content = item.findtext("{http://purl.org/rss/1.0/modules/content/}encoded") or "" + self.assertNotIn("<h1>Тестовый заголовок</h1>", content) + self.assertIn("<p>Тестовый лид.</p>", content) + self.assertIn("<p>Основной текст.</p>", content) + + +if __name__ == "__main__": + unittest.main() +``` + +- [ ] **Step 2: Run the focused test and verify the current behavior fails** + +Run: + +```bash +docker run --rm \ + -e PYTHONPYCACHEPREFIX=/tmp/pycache \ + -v "$PWD:/workspace:ro" \ + -w /workspace \ + dzen-assistant-test:local \ + python -m unittest tests.test_rss -v +``` + +Expected: one failure because `content:encoded` contains `<h1>Тестовый заголовок</h1>`. + +- [ ] **Step 3: Use the existing renderer as the complete RSS body** + +In `app/rss.py`, replace the body construction inside `build_feed_xml` with: + +```python +content = render_article_html(article, rss_safe=True) +``` + +Do not change the item `<title>`, cover caption, description, or article page renderer. + +- [ ] **Step 4: Run the focused test and verify it passes** + +Run the command from Step 2. + +Expected: `Ran 1 test` followed by `OK`. + +- [ ] **Step 5: Run the backend regression suite and compilation** + +Run: + +```bash +docker run --rm \ + -e PYTHONPYCACHEPREFIX=/tmp/pycache \ + -v "$PWD:/workspace:ro" \ + -w /workspace \ + dzen-assistant-test:local \ + python -m unittest discover -s tests -v + +docker run --rm \ + -e PYTHONPYCACHEPREFIX=/tmp/pycache \ + -v "$PWD:/workspace:ro" \ + -w /workspace \ + dzen-assistant-test:local \ + python -m compileall -q app tests +``` + +Expected: all tests pass and compilation exits with status 0. + +- [ ] **Step 6: Commit the implementation** + +```bash +git add app/rss.py tests/test_rss.py +git commit -m "fix: avoid duplicate article titles in RSS bodies" +```