social-mi-bi/scripts/seed_benchmarks.py
Dave Porter fb5acdb892 Initial commit: social MI/BI multi-agent reporting tool
4-stage agent pipeline (Data Mapper, Input Collector, Strategy Writer, Report
Builder) with React wizard, Postgres persistence, HITL + YOLO modes, Apify
embed hydration, clone-for-next-month, and slide-deck HTML output.

Proven end-to-end against real Cif Meltwater data (Instagram + TikTok) with
Anthropic Opus 4.7 (strategy) and Sonnet 4.6 (report builder).
2026-04-17 17:07:44 -04:00

53 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Seed `benchmarks` table — idempotent. Invoked by bootstrap on boot too."""
from __future__ import annotations
import asyncio
from datetime import date
from sqlalchemy import select
from app.db import session_scope
from app.models import Benchmark, Platform
DEFAULT_BENCHMARKS = {
"instagram": {"posts": 10, "views_growth": 40, "er": 2.0, "vtr": 10.0},
"tiktok": {"posts": 10, "views_growth": 40, "er": 2.0, "vtr": 10.0},
"facebook": {"posts": 10, "views_growth": 20, "er": 1.5, "vtr": 8.0},
}
EFFECTIVE_FROM = date(2026, 1, 1)
async def _main() -> None:
async with session_scope() as db:
plats = (await db.execute(select(Platform))).scalars().all()
slug_to_id = {p.slug: p.id for p in plats}
for slug, metrics in DEFAULT_BENCHMARKS.items():
platform_id = slug_to_id.get(slug)
if platform_id is None:
continue
for metric, value in metrics.items():
existing = (
await db.execute(
select(Benchmark).where(
Benchmark.platform_id == platform_id,
Benchmark.metric == metric,
Benchmark.effective_from == EFFECTIVE_FROM,
)
)
).scalar_one_or_none()
if existing is None:
db.add(
Benchmark(
platform_id=platform_id,
metric=metric,
value=value,
effective_from=EFFECTIVE_FROM,
)
)
print("benchmarks seeded")
if __name__ == "__main__":
asyncio.run(_main())