Some checks failed
Tick / tick (push) Failing after 1s
- Risk rules: up to 2 positions of ~100 EUR under 400 EUR (3 up to 1000, 4 above), so the AI pot can buy several times a week - One Sonnet call per day compares up to 6 candidates (news + screener) and reviews AI pot and sandbox holdings; the AI pot sells and buys on its own, through the deterministic risk engine - Sandbox: "Le conseil de l'IA" card (what to buy, sell, keep) with one-tap follow - Monthly budget of 100 EUR (half PEA S&P 500, half CTO) enforced when saving the account and the PEA plan, shown on Mon compte - Vercel cron backup (weekday evenings) next to GitHub Actions; the tick endpoint records who woke the app, shown in Reglages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import "server-only";
|
|
import { and, desc, gte, isNotNull } from "drizzle-orm";
|
|
import { aiEnabled, getAiSpend } from "./ai";
|
|
import { getDb, schema } from "./db";
|
|
import type { RunLog } from "./jobs";
|
|
import { getKv } from "./settings";
|
|
|
|
/** Ce qu'il faut savoir pour comprendre pourquoi l'IA trade (ou pas). */
|
|
export async function getDiagnostics() {
|
|
const db = await getDb();
|
|
const since48h = new Date(Date.now() - 48 * 3_600_000);
|
|
const since7d = new Date(Date.now() - 7 * 86_400_000);
|
|
const [wakeGithub, wakeVercel, wakeShortcut] = await Promise.all([
|
|
getKv<string>("lastWake:github"),
|
|
getKv<string>("lastWake:vercel"),
|
|
getKv<string>("lastWake:raccourci"),
|
|
]);
|
|
const [news, triaged, signals, spend, lastTick, lastEvening] = await Promise.all([
|
|
db.select({ id: schema.news.id }).from(schema.news).where(gte(schema.news.publishedAt, since48h)),
|
|
db
|
|
.select({ triage: schema.news.triage })
|
|
.from(schema.news)
|
|
.where(and(isNotNull(schema.news.triagedAt), gte(schema.news.publishedAt, since48h))),
|
|
db.select().from(schema.signals).where(gte(schema.signals.createdAt, since7d)).orderBy(desc(schema.signals.createdAt)).limit(10),
|
|
getAiSpend(),
|
|
getKv<RunLog>("lastTickLog"),
|
|
getKv<RunLog>("lastEveningLog"),
|
|
]);
|
|
const scored = triaged.filter((t) => t.triage && t.triage.reason !== "Non évaluée.");
|
|
return {
|
|
aiOn: aiEnabled(),
|
|
cronConfigured: Boolean(process.env.CRON_SECRET),
|
|
wakes: { github: wakeGithub, vercel: wakeVercel, shortcut: wakeShortcut },
|
|
news48h: news.length,
|
|
triagedTotal: triaged.length,
|
|
positiveStrong: scored.filter((t) => t.triage!.direction === "positive" && t.triage!.relevance >= 6).length,
|
|
signals,
|
|
spend,
|
|
lastTick,
|
|
lastEvening,
|
|
};
|
|
}
|