33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
# Procyon — self-improvement loop. Logs outcomes, surfaces what works.
|
|
|
|
import db
|
|
|
|
|
|
def log_outcome(app_id, stage, notes=''):
|
|
db.add_outcome(app_id, stage, notes)
|
|
db.update_application(app_id, status=stage)
|
|
|
|
|
|
def insights():
|
|
"""Aggregate outcomes -> simple actionable insights."""
|
|
conn = db.get_conn()
|
|
try:
|
|
rows = conn.execute(
|
|
'SELECT stage, COUNT(*) c FROM outcomes GROUP BY stage').fetchall()
|
|
sent = conn.execute(
|
|
"SELECT COUNT(*) c FROM applications WHERE outcome IN ('response','interview','offer')"
|
|
).fetchone()['c']
|
|
total = conn.execute('SELECT COUNT(*) c FROM applications').fetchone()['c']
|
|
by_stage = {r['stage']: r['c'] for r in rows}
|
|
resp_rate = round(sent / total, 3) if total else 0.0
|
|
return {
|
|
'total_applications': total,
|
|
'by_stage': by_stage,
|
|
'positive_outcomes': sent,
|
|
'response_rate': resp_rate,
|
|
'note': ('Response rate is positive-outcome / total applications. '
|
|
'Higher = your tailoring and targeting are landing.'),
|
|
}
|
|
finally:
|
|
conn.close()
|