Merge pull request 'feat(style-acq T8): analyze_corpus — הסרת LIMIT 20 (כיסוי מלא)' (#89) from worktree-style-acquisition-mvp into main
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m24s

This commit was merged in pull request #89.
This commit is contained in:
2026-06-06 19:25:40 +00:00

View File

@@ -109,26 +109,30 @@ SYNTHESIS_PROMPT = """\
"""
async def analyze_corpus(appeal_subtype: str = "") -> dict:
async def analyze_corpus(appeal_subtype: str = "", limit: int = 0) -> dict:
"""Analyze the style corpus and extract/update patterns.
Args:
appeal_subtype: filter by appeal subtype (e.g. 'betterment_levy', 'building_permit').
Empty string = all decisions.
limit: max decisions to analyze. 0 = ALL (T8 — full 48/48 coverage feeds the
author-features the writer's profile relies on; the old LIMIT 20 silently
dropped a third of Dafna's corpus).
Returns summary of patterns found.
"""
pool = await db.get_pool()
lim_sql = f" LIMIT {int(limit)}" if limit and limit > 0 else ""
async with pool.acquire() as conn:
if appeal_subtype:
rows = await conn.fetch(
"SELECT full_text, decision_number FROM style_corpus "
"WHERE appeal_subtype = $1 ORDER BY decision_date DESC LIMIT 20",
"WHERE appeal_subtype = $1 ORDER BY decision_date DESC" + lim_sql,
appeal_subtype,
)
else:
rows = await conn.fetch(
"SELECT full_text, decision_number FROM style_corpus ORDER BY decision_date DESC LIMIT 20"
"SELECT full_text, decision_number FROM style_corpus ORDER BY decision_date DESC" + lim_sql
)
if not rows: