Paid detailed analyses with per-kind units; example analysis page
- Credits become analysis units (migration 0006): a natal analysis uses one 'natal' unit, a synastry analysis one 'synastry' unit. No monthly free credits, no model tiers: ANALYSIS_MODEL (default Opus 5.5) writes every paid analysis. Admins grant units per kind; the worker refunds the right unit on failure. - Chart page: the detailed analysis card (offer with units left and a confirmation, progress while writing, the finished six sections). - Public /pelda page: a full Opus analysis of a made-up chart, with the free summary and a login call to action. - The worker sends the JSON schema with properties in 'required' order. serde_json sorted them, so the title came after ~9000 tokens of text and Opus sometimes left it empty (3 failed attempts in a live test); with the order fixed the same analysis succeeded at the first try. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -4,6 +4,7 @@ import { notFound } from "next/navigation";
|
||||
|
||||
import { BigThree, ChartTables } from "@/components/ChartTables";
|
||||
import { ChartSummary } from "@/components/ChartSummary";
|
||||
import { DetailedAnalysis } from "@/components/DetailedAnalysis";
|
||||
import { ChartWheel } from "@/components/ChartWheel";
|
||||
import { ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
@@ -16,14 +17,17 @@ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
/** One saved chart: the wheel and the tables, read from the database (not recalculated). */
|
||||
export default async function ChartPage({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
await requireMe(`/kepletek/${id}`);
|
||||
const me = await requireMe(`/kepletek/${id}`);
|
||||
if (!UUID.test(id)) notFound();
|
||||
const [chart, analyses] = await Promise.all([
|
||||
backendGet<Chart>(`/v1/charts/${id}`),
|
||||
backendGet<{ analyses: Analysis[] }>(`/v1/charts/${id}/analyses`),
|
||||
]);
|
||||
if (!chart) notFound();
|
||||
const summary = analyses?.analyses.find((a) => a.kind === "summary" && a.status !== "failed") ?? null;
|
||||
const list = analyses?.analyses ?? [];
|
||||
const summary = list.find((a) => a.kind === "summary" && a.status !== "failed") ?? null;
|
||||
const natal = list.filter((a) => a.kind === "natal");
|
||||
const detailed = natal.find((a) => a.status !== "failed") ?? natal[0] ?? null;
|
||||
|
||||
const result = chart.chart;
|
||||
const timeKnown = chart.highlights.time_known;
|
||||
@@ -110,6 +114,8 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<DetailedAnalysis chartId={chart.id} initial={detailed} left={me.analyses_left.natal} />
|
||||
|
||||
<section className="card" aria-labelledby="positions">
|
||||
<h2 id="positions">Pozíciók</h2>
|
||||
<ChartTables chart={chart} />
|
||||
|
||||
Reference in New Issue
Block a user