feat: pass variant blog fields (slug, tags, seo_description) to strategy extra dict
This commit is contained in:
parent
e7316d177f
commit
774fbb37c3
2 changed files with 12 additions and 6 deletions
|
|
@ -180,6 +180,9 @@ class Store:
|
||||||
title: str,
|
title: str,
|
||||||
body: str,
|
body: str,
|
||||||
flair: str | None = None,
|
flair: str | None = None,
|
||||||
|
slug: str | None = None,
|
||||||
|
tags: str | None = None,
|
||||||
|
seo_description: str | None = None,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
existing = self._fetchone(
|
existing = self._fetchone(
|
||||||
"SELECT * FROM campaign_variants WHERE campaign_id = ? AND sub_pattern = ?",
|
"SELECT * FROM campaign_variants WHERE campaign_id = ? AND sub_pattern = ?",
|
||||||
|
|
@ -187,15 +190,15 @@ class Store:
|
||||||
)
|
)
|
||||||
if existing:
|
if existing:
|
||||||
self.conn.execute(
|
self.conn.execute(
|
||||||
"UPDATE campaign_variants SET title=?, body=?, flair=? WHERE id=?",
|
"UPDATE campaign_variants SET title=?, body=?, flair=?, slug=?, tags=?, seo_description=? WHERE id=?",
|
||||||
(title, body, flair, existing["id"]),
|
(title, body, flair, slug, tags, seo_description, existing["id"]),
|
||||||
)
|
)
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
return self._fetchone("SELECT * FROM campaign_variants WHERE id=?", (existing["id"],))
|
return self._fetchone("SELECT * FROM campaign_variants WHERE id=?", (existing["id"],))
|
||||||
return self._insert_returning(
|
return self._insert_returning(
|
||||||
"INSERT INTO campaign_variants (campaign_id, sub_pattern, title, body, flair)"
|
"INSERT INTO campaign_variants (campaign_id, sub_pattern, title, body, flair, slug, tags, seo_description)"
|
||||||
" VALUES (?,?,?,?,?) RETURNING *",
|
" VALUES (?,?,?,?,?,?,?,?) RETURNING *",
|
||||||
(campaign_id, sub_pattern, title, body, flair),
|
(campaign_id, sub_pattern, title, body, flair, slug, tags, seo_description),
|
||||||
)
|
)
|
||||||
|
|
||||||
def update_variant(self, variant_id: int, **fields) -> dict | None:
|
def update_variant(self, variant_id: int, **fields) -> dict | None:
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,11 @@ def _run_post(db_path: str, campaign_id: int, target: str,
|
||||||
)
|
)
|
||||||
post_id = post["id"]
|
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)
|
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
|
# Execute strategy
|
||||||
flair = variant.get("flair") or (rules.get("flair_to_use") if rules else None)
|
flair = variant.get("flair") or (rules.get("flair_to_use") if rules else None)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue