From 774fbb37c34b0abd4b1dabba18f3f5fd47f682cd Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 27 Apr 2026 16:11:04 -0700 Subject: [PATCH] feat: pass variant blog fields (slug, tags, seo_description) to strategy extra dict --- app/db/store.py | 13 ++++++++----- app/services/poster.py | 5 ++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/db/store.py b/app/db/store.py index 5de8b6c..5165acd 100644 --- a/app/db/store.py +++ b/app/db/store.py @@ -180,6 +180,9 @@ class Store: title: str, body: str, flair: str | None = None, + slug: str | None = None, + tags: str | None = None, + seo_description: str | None = None, ) -> dict: existing = self._fetchone( "SELECT * FROM campaign_variants WHERE campaign_id = ? AND sub_pattern = ?", @@ -187,15 +190,15 @@ class Store: ) if existing: self.conn.execute( - "UPDATE campaign_variants SET title=?, body=?, flair=? WHERE id=?", - (title, body, flair, existing["id"]), + "UPDATE campaign_variants SET title=?, body=?, flair=?, slug=?, tags=?, seo_description=? WHERE id=?", + (title, body, flair, slug, tags, seo_description, existing["id"]), ) self.conn.commit() return self._fetchone("SELECT * FROM campaign_variants WHERE id=?", (existing["id"],)) return self._insert_returning( - "INSERT INTO campaign_variants (campaign_id, sub_pattern, title, body, flair)" - " VALUES (?,?,?,?,?) RETURNING *", - (campaign_id, sub_pattern, title, body, flair), + "INSERT INTO campaign_variants (campaign_id, sub_pattern, title, body, flair, slug, tags, seo_description)" + " VALUES (?,?,?,?,?,?,?,?) RETURNING *", + (campaign_id, sub_pattern, title, body, flair, slug, tags, seo_description), ) def update_variant(self, variant_id: int, **fields) -> dict | None: diff --git a/app/services/poster.py b/app/services/poster.py index e17bf66..8eca02e 100644 --- a/app/services/poster.py +++ b/app/services/poster.py @@ -77,8 +77,11 @@ def _run_post(db_path: str, campaign_id: int, target: str, ) post_id = post["id"] - # Build extra dict from sub_row + # Build extra dict from sub_row; merge variant-level blog fields (blog_post strategy uses them) extra = dict(sub_row) + for field in ("slug", "tags", "seo_description"): + if variant.get(field) is not None: + extra.setdefault(field, variant[field]) # Execute strategy flair = variant.get("flair") or (rules.get("flair_to_use") if rules else None)