fix: PostgreSQL boolean syntax in prompts queries
- Change WHERE active=1 to WHERE active=true (PostgreSQL uses boolean) - Change endpoint from /api/ai/prompts to /api/prompts (simpler path) - Fixed 5 occurrences across prompt-related queries This fixes the issue where no prompts were returned, causing empty prompt list in Admin and no AI analysis options. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8390c7f510
commit
36f334aba7
|
|
@ -842,7 +842,7 @@ async def analyze_with_prompt(slug: str, x_profile_id: Optional[str]=Header(defa
|
|||
# Get prompt template
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("SELECT * FROM ai_prompts WHERE slug=%s AND active=1", (slug,))
|
||||
cur.execute("SELECT * FROM ai_prompts WHERE slug=%s AND active=true", (slug,))
|
||||
prompt_row = cur.fetchone()
|
||||
if not prompt_row:
|
||||
raise HTTPException(404, f"Prompt '{slug}' nicht gefunden")
|
||||
|
|
@ -902,7 +902,7 @@ async def analyze_pipeline(x_profile_id: Optional[str]=Header(default=None), ses
|
|||
# Stage 1: Parallel JSON analyses
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("SELECT slug, template FROM ai_prompts WHERE slug LIKE 'pipeline_%' AND slug NOT IN ('pipeline_synthesis','pipeline_goals') AND active=1")
|
||||
cur.execute("SELECT slug, template FROM ai_prompts WHERE slug LIKE 'pipeline_%' AND slug NOT IN ('pipeline_synthesis','pipeline_goals') AND active=true")
|
||||
stage1_prompts = [r2d(r) for r in cur.fetchall()]
|
||||
|
||||
stage1_results = {}
|
||||
|
|
@ -947,7 +947,7 @@ async def analyze_pipeline(x_profile_id: Optional[str]=Header(default=None), ses
|
|||
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("SELECT template FROM ai_prompts WHERE slug='pipeline_synthesis' AND active=1")
|
||||
cur.execute("SELECT template FROM ai_prompts WHERE slug='pipeline_synthesis' AND active=true")
|
||||
synth_row = cur.fetchone()
|
||||
if not synth_row:
|
||||
raise HTTPException(500, "Pipeline synthesis prompt not found")
|
||||
|
|
@ -984,7 +984,7 @@ async def analyze_pipeline(x_profile_id: Optional[str]=Header(default=None), ses
|
|||
if prof.get('goal_weight') or prof.get('goal_bf_pct'):
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("SELECT template FROM ai_prompts WHERE slug='pipeline_goals' AND active=1")
|
||||
cur.execute("SELECT template FROM ai_prompts WHERE slug='pipeline_goals' AND active=true")
|
||||
goals_row = cur.fetchone()
|
||||
if goals_row:
|
||||
goals_prompt = _render_template(goals_row['template'], vars)
|
||||
|
|
@ -1026,12 +1026,12 @@ async def analyze_pipeline(x_profile_id: Optional[str]=Header(default=None), ses
|
|||
inc_ai_usage(pid)
|
||||
return {"scope": "gesamt", "content": final_content, "stage1": stage1_results}
|
||||
|
||||
@app.get("/api/ai/prompts")
|
||||
@app.get("/api/prompts")
|
||||
def list_prompts(session: dict=Depends(require_auth)):
|
||||
"""List all available AI prompts."""
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("SELECT * FROM ai_prompts WHERE active=1 AND slug NOT LIKE 'pipeline_%' ORDER BY sort_order")
|
||||
cur.execute("SELECT * FROM ai_prompts WHERE active=true AND slug NOT LIKE 'pipeline_%' ORDER BY sort_order")
|
||||
return [r2d(r) for r in cur.fetchall()]
|
||||
|
||||
@app.get("/api/ai/usage")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user