feat(style-acq T8): analyze_corpus — הסרת LIMIT 20 (כיסוי מלא) #89

Merged
chaim merged 1 commits from worktree-style-acquisition-mvp into main 2026-06-06 19:25:41 +00:00
Showing only changes of commit 5fa76a09b4 - Show all commits

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. """Analyze the style corpus and extract/update patterns.
Args: Args:
appeal_subtype: filter by appeal subtype (e.g. 'betterment_levy', 'building_permit'). appeal_subtype: filter by appeal subtype (e.g. 'betterment_levy', 'building_permit').
Empty string = all decisions. 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. Returns summary of patterns found.
""" """
pool = await db.get_pool() pool = await db.get_pool()
lim_sql = f" LIMIT {int(limit)}" if limit and limit > 0 else ""
async with pool.acquire() as conn: async with pool.acquire() as conn:
if appeal_subtype: if appeal_subtype:
rows = await conn.fetch( rows = await conn.fetch(
"SELECT full_text, decision_number FROM style_corpus " "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, appeal_subtype,
) )
else: else:
rows = await conn.fetch( 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: if not rows: