清理残留 skip_polymarket 参数和 PM 注释
This commit is contained in:
@@ -30,7 +30,6 @@ export async function GET(req: NextRequest) {
|
|||||||
"time_range",
|
"time_range",
|
||||||
"limit",
|
"limit",
|
||||||
"force_refresh",
|
"force_refresh",
|
||||||
"skip_polymarket",
|
|
||||||
"timezone_offset_seconds",
|
"timezone_offset_seconds",
|
||||||
]) {
|
]) {
|
||||||
const value = req.nextUrl.searchParams.get(key);
|
const value = req.nextUrl.searchParams.get(key);
|
||||||
|
|||||||
@@ -287,6 +287,8 @@ type HourlyForecast = {
|
|||||||
amos?: AmosData | null;
|
amos?: AmosData | null;
|
||||||
airportCurrent?: AirportCurrentConditions | null;
|
airportCurrent?: AirportCurrentConditions | null;
|
||||||
airportPrimary?: AirportCurrentConditions | null;
|
airportPrimary?: AirportCurrentConditions | null;
|
||||||
|
forecastDaily?: ForecastDay[];
|
||||||
|
multiModelDaily?: Record<string, DailyModelForecast>;
|
||||||
} | null;
|
} | null;
|
||||||
|
|
||||||
function parseRunwayHistoryValue(point: Record<string, unknown>) {
|
function parseRunwayHistoryValue(point: Record<string, unknown>) {
|
||||||
@@ -383,6 +385,219 @@ function buildRunwayHistorySeries(
|
|||||||
.filter((series): series is RunwayHistorySeries => series !== null);
|
.filter((series): series is RunwayHistorySeries => series !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generate3DaySlots(localDateStr: string): number[] {
|
||||||
|
const parts = localDateStr.split("-");
|
||||||
|
if (parts.length !== 3) return [];
|
||||||
|
const year = parseInt(parts[0], 10);
|
||||||
|
const month = parseInt(parts[1], 10) - 1;
|
||||||
|
const day = parseInt(parts[2], 10);
|
||||||
|
|
||||||
|
const slots: number[] = [];
|
||||||
|
// Generate 72 hours starting from local date 00:00
|
||||||
|
for (let h = 0; h < 72; h++) {
|
||||||
|
slots.push(Date.UTC(year, month, day, h, 0));
|
||||||
|
}
|
||||||
|
return slots;
|
||||||
|
}
|
||||||
|
|
||||||
|
function format3DayTimestamp(ts: number): string {
|
||||||
|
const d = new Date(ts);
|
||||||
|
const mm = String(d.getUTCMonth() + 1).padStart(2, "0");
|
||||||
|
const dd = String(d.getUTCDate()).padStart(2, "0");
|
||||||
|
const hh = String(d.getUTCHours()).padStart(2, "0");
|
||||||
|
return `${mm}/${dd} ${hh}:00`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function build3DayChartData(
|
||||||
|
row: ScanOpportunityRow | null,
|
||||||
|
hourly: HourlyForecast,
|
||||||
|
): { data: Array<Record<string, string | number | null>>; series: EvidenceSeries[] } {
|
||||||
|
const tzOffset = row?.tz_offset_seconds ?? 0;
|
||||||
|
const localDateStr = row?.local_date || new Date().toISOString().slice(0, 10);
|
||||||
|
|
||||||
|
const slots = generate3DaySlots(localDateStr);
|
||||||
|
if (!slots.length) return { data: [], series: [] };
|
||||||
|
const n = slots.length;
|
||||||
|
|
||||||
|
const series: EvidenceSeries[] = [];
|
||||||
|
const na = (): Array<number | null> => new Array(n).fill(null);
|
||||||
|
|
||||||
|
// DEB forecast curve (from hourly.times & hourly.temps)
|
||||||
|
if (hourly?.times?.length && hourly?.temps?.length) {
|
||||||
|
const debVals = na();
|
||||||
|
hourly.times.forEach((t, i) => {
|
||||||
|
const ts = getCityLocalUtcTimestamp(t, tzOffset, localDateStr);
|
||||||
|
if (ts === null) return;
|
||||||
|
const slotIdx = slots.findIndex((s) => s === ts);
|
||||||
|
if (slotIdx >= 0) {
|
||||||
|
debVals[slotIdx] = validNumber(hourly.temps[i]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (debVals.some((v) => v !== null)) {
|
||||||
|
series.push({
|
||||||
|
key: "hourly_forecast",
|
||||||
|
label: "DEB Forecast",
|
||||||
|
source: "DEB Hourly",
|
||||||
|
color: "#f97316",
|
||||||
|
featured: true,
|
||||||
|
smooth: true,
|
||||||
|
values: debVals,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Per-model curves
|
||||||
|
if (hourly.modelCurves) {
|
||||||
|
const modelColors = ["#2563eb", "#7c3aed", "#059669", "#d97706", "#dc2626", "#0891b2"];
|
||||||
|
Object.keys(hourly.modelCurves).forEach((model, idx) => {
|
||||||
|
const modelTemps = hourly.modelCurves![model];
|
||||||
|
if (!modelTemps?.length) return;
|
||||||
|
const vals = na();
|
||||||
|
hourly.times.forEach((t, i) => {
|
||||||
|
const ts = getCityLocalUtcTimestamp(t, tzOffset, localDateStr);
|
||||||
|
if (ts === null) return;
|
||||||
|
const slotIdx = slots.findIndex((s) => s === ts);
|
||||||
|
if (slotIdx >= 0 && i < modelTemps.length) {
|
||||||
|
vals[slotIdx] = validNumber(modelTemps[i]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (vals.some((v) => v !== null)) {
|
||||||
|
series.push({
|
||||||
|
key: `model_curve_${model}`,
|
||||||
|
label: model,
|
||||||
|
source: "Multi-model hourly",
|
||||||
|
color: modelColors[idx % modelColors.length],
|
||||||
|
dashed: true,
|
||||||
|
smooth: true,
|
||||||
|
values: vals,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Historical METAR observations (past timestamps of the 3 days)
|
||||||
|
const metarObs = normObs(
|
||||||
|
row?.metar_today_obs || row?.metar_context?.today_obs || row?.metar_recent_obs || row?.metar_context?.recent_obs,
|
||||||
|
tzOffset
|
||||||
|
);
|
||||||
|
if (metarObs.length) {
|
||||||
|
const mvals = binObservationsToSlots(slots, metarObs);
|
||||||
|
if (mvals.some((v) => v !== null)) {
|
||||||
|
series.push({
|
||||||
|
key: "metar",
|
||||||
|
label: "METAR",
|
||||||
|
source: row?.airport || "METAR",
|
||||||
|
color: "#0ea5e9",
|
||||||
|
dashed: true,
|
||||||
|
values: mvals,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build data rows
|
||||||
|
const data = slots.map((ts, i) => {
|
||||||
|
const point: Record<string, string | number | null> = {
|
||||||
|
label: format3DayTimestamp(ts),
|
||||||
|
ts,
|
||||||
|
};
|
||||||
|
series.forEach((s) => {
|
||||||
|
point[s.key] = s.values[i] ?? null;
|
||||||
|
});
|
||||||
|
return point;
|
||||||
|
});
|
||||||
|
|
||||||
|
return { data, series };
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateDailySlots(localDateStr: string, daysCount: number): string[] {
|
||||||
|
const parts = localDateStr.split("-");
|
||||||
|
if (parts.length !== 3) return [];
|
||||||
|
const year = parseInt(parts[0], 10);
|
||||||
|
const month = parseInt(parts[1], 10) - 1;
|
||||||
|
const day = parseInt(parts[2], 10);
|
||||||
|
|
||||||
|
const dates: string[] = [];
|
||||||
|
for (let i = 0; i < daysCount; i++) {
|
||||||
|
const d = new Date(Date.UTC(year, month, day + i));
|
||||||
|
const yyyy = d.getUTCFullYear();
|
||||||
|
const mm = String(d.getUTCMonth() + 1).padStart(2, "0");
|
||||||
|
const dd = String(d.getUTCDate()).padStart(2, "0");
|
||||||
|
dates.push(`${yyyy}-${mm}-${dd}`);
|
||||||
|
}
|
||||||
|
return dates;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDailyDateLabel(dateStr: string): string {
|
||||||
|
const parts = dateStr.split("-");
|
||||||
|
if (parts.length !== 3) return dateStr;
|
||||||
|
return `${parts[1]}/${parts[2]}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildDailyChartData(
|
||||||
|
row: ScanOpportunityRow | null,
|
||||||
|
hourly: HourlyForecast,
|
||||||
|
daysCount: number,
|
||||||
|
): { data: Array<Record<string, string | number | null>>; series: EvidenceSeries[] } {
|
||||||
|
const localDateStr = row?.local_date || new Date().toISOString().slice(0, 10);
|
||||||
|
const slots = generateDailySlots(localDateStr, daysCount);
|
||||||
|
|
||||||
|
const series: EvidenceSeries[] = [
|
||||||
|
{
|
||||||
|
key: "deb_prediction",
|
||||||
|
label: "DEB Daily Max",
|
||||||
|
source: "DEB",
|
||||||
|
color: "#f97316", // orange
|
||||||
|
featured: true,
|
||||||
|
values: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "max_temp",
|
||||||
|
label: "Model Daily Max",
|
||||||
|
source: "Standard Forecast",
|
||||||
|
color: "#dc2626", // red
|
||||||
|
dashed: true,
|
||||||
|
values: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "min_temp",
|
||||||
|
label: "Model Daily Min",
|
||||||
|
source: "Standard Forecast",
|
||||||
|
color: "#2563eb", // blue
|
||||||
|
dashed: true,
|
||||||
|
values: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const data = slots.map((dateStr) => {
|
||||||
|
const dayForecast = hourly?.forecastDaily?.find((d) => d.date === dateStr);
|
||||||
|
const dayMultiModel = hourly?.multiModelDaily?.[dateStr];
|
||||||
|
|
||||||
|
const label = formatDailyDateLabel(dateStr);
|
||||||
|
|
||||||
|
const debMax = validNumber(dayMultiModel?.deb?.prediction) ?? (dateStr === localDateStr ? validNumber(row?.deb_prediction) : null);
|
||||||
|
const maxTemp = validNumber(dayForecast?.max_temp);
|
||||||
|
const minTemp = validNumber(dayForecast?.min_temp);
|
||||||
|
|
||||||
|
return {
|
||||||
|
label,
|
||||||
|
date: dateStr,
|
||||||
|
deb_prediction: debMax,
|
||||||
|
max_temp: maxTemp,
|
||||||
|
min_temp: minTemp,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Populate series values
|
||||||
|
series[0].values = data.map((d) => d.deb_prediction);
|
||||||
|
series[1].values = data.map((d) => d.max_temp);
|
||||||
|
series[2].values = data.map((d) => d.min_temp);
|
||||||
|
|
||||||
|
// Filter out series that have no valid data points
|
||||||
|
const activeSeries = series.filter((s) => s.values.some((v) => v !== null));
|
||||||
|
|
||||||
|
return { data, series: activeSeries };
|
||||||
|
}
|
||||||
|
|
||||||
function buildFullDayChartData(
|
function buildFullDayChartData(
|
||||||
row: ScanOpportunityRow | null,
|
row: ScanOpportunityRow | null,
|
||||||
hourly: HourlyForecast,
|
hourly: HourlyForecast,
|
||||||
@@ -616,13 +831,21 @@ export function LiveTemperatureThresholdChart({
|
|||||||
isEn,
|
isEn,
|
||||||
row,
|
row,
|
||||||
allRows = [],
|
allRows = [],
|
||||||
|
compact = false,
|
||||||
}: {
|
}: {
|
||||||
isEn: boolean;
|
isEn: boolean;
|
||||||
row: ScanOpportunityRow | null;
|
row: ScanOpportunityRow | null;
|
||||||
allRows?: ScanOpportunityRow[];
|
allRows?: ScanOpportunityRow[];
|
||||||
|
compact?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const [hourly, setHourly] = useState<HourlyForecast>(null);
|
const [hourly, setHourly] = useState<HourlyForecast>(null);
|
||||||
const city = String(row?.city || "").toLowerCase().trim();
|
const city = String(row?.city || "").toLowerCase().trim();
|
||||||
|
const [timeframe, setTimeframe] = useState<"1D" | "3D" | "5D" | "7D">("1D");
|
||||||
|
const [hiddenSeriesKeys, setHiddenSeriesKeys] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setHiddenSeriesKeys(new Set());
|
||||||
|
}, [timeframe]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!city) return;
|
if (!city) return;
|
||||||
@@ -653,6 +876,8 @@ export function LiveTemperatureThresholdChart({
|
|||||||
amos: json.amos || null,
|
amos: json.amos || null,
|
||||||
airportCurrent: json.airport_current || null,
|
airportCurrent: json.airport_current || null,
|
||||||
airportPrimary: json.airport_primary || null,
|
airportPrimary: json.airport_primary || null,
|
||||||
|
forecastDaily: json.forecast?.daily || [],
|
||||||
|
multiModelDaily: json.multi_model_daily || {},
|
||||||
};
|
};
|
||||||
_hourlyCache.set(city, { ts: Date.now(), data });
|
_hourlyCache.set(city, { ts: Date.now(), data });
|
||||||
setHourly(data);
|
setHourly(data);
|
||||||
@@ -661,8 +886,18 @@ export function LiveTemperatureThresholdChart({
|
|||||||
return () => { cancelled = true; };
|
return () => { cancelled = true; };
|
||||||
}, [city]);
|
}, [city]);
|
||||||
|
|
||||||
const { data, series } = useMemo(() => buildFullDayChartData(row, hourly), [row, hourly]);
|
const { data, series } = useMemo(() => {
|
||||||
const [hiddenSeriesKeys, setHiddenSeriesKeys] = useState<Set<string>>(new Set());
|
if (timeframe === "3D") {
|
||||||
|
return build3DayChartData(row, hourly);
|
||||||
|
}
|
||||||
|
if (timeframe === "5D") {
|
||||||
|
return buildDailyChartData(row, hourly, 5);
|
||||||
|
}
|
||||||
|
if (timeframe === "7D") {
|
||||||
|
return buildDailyChartData(row, hourly, 7);
|
||||||
|
}
|
||||||
|
return buildFullDayChartData(row, hourly);
|
||||||
|
}, [row, hourly, timeframe]);
|
||||||
|
|
||||||
const tzOffset = row?.tz_offset_seconds ?? 0;
|
const tzOffset = row?.tz_offset_seconds ?? 0;
|
||||||
const settlementObs = useMemo(() => {
|
const settlementObs = useMemo(() => {
|
||||||
@@ -674,8 +909,11 @@ export function LiveTemperatureThresholdChart({
|
|||||||
const settlementPlate = useMemo(() => runwayPlates.find((p) => p.isSettlement), [runwayPlates]);
|
const settlementPlate = useMemo(() => runwayPlates.find((p) => p.isSettlement), [runwayPlates]);
|
||||||
|
|
||||||
const chartSeries = useMemo(() => {
|
const chartSeries = useMemo(() => {
|
||||||
|
if (timeframe !== "1D") {
|
||||||
|
return series;
|
||||||
|
}
|
||||||
return series.filter((item) => !hasRunwayData || !item.key.startsWith("model_curve_"));
|
return series.filter((item) => !hasRunwayData || !item.key.startsWith("model_curve_"));
|
||||||
}, [series, hasRunwayData]);
|
}, [series, hasRunwayData, timeframe]);
|
||||||
|
|
||||||
const activeSeries = useMemo(() => {
|
const activeSeries = useMemo(() => {
|
||||||
return chartSeries.filter((s) => !hiddenSeriesKeys.has(s.key));
|
return chartSeries.filter((s) => !hiddenSeriesKeys.has(s.key));
|
||||||
@@ -771,90 +1009,186 @@ export function LiveTemperatureThresholdChart({
|
|||||||
[series, data],
|
[series, data],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
const panelTitle = row
|
||||||
<Panel title={isEn ? "Live Temperature Trend & Option Threshold Lines" : "实时气温走势与期权阈值线"}>
|
? `${rowName(row)} · ${
|
||||||
<div className="flex h-full min-h-[420px] flex-col">
|
isEn
|
||||||
{/* Stats bar */}
|
? timeframe === "1D"
|
||||||
<div className="shrink-0 border-b border-slate-200 bg-white px-4 py-3">
|
? "Live & Forecast"
|
||||||
{/* Top Row: Large temperatures */}
|
: `${timeframe} Forecast`
|
||||||
<div className="flex justify-between items-center gap-6 mb-3">
|
: timeframe === "1D"
|
||||||
<div className="flex items-center gap-12">
|
? "实测与预测"
|
||||||
<div className="flex flex-col">
|
: `${timeframe}预报`
|
||||||
<span className="text-[11px] font-semibold text-slate-500 uppercase tracking-wider">
|
}`
|
||||||
{isEn ? "Runway Live (1m)" : `${runwayHeaderLabel}`}
|
: isEn
|
||||||
</span>
|
? "Temperature Chart"
|
||||||
<span className="text-2xl font-bold font-mono text-[#009688] mt-1">
|
: "气温图表";
|
||||||
{temp(currentRunwayTemp)}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-col">
|
|
||||||
<span className="text-[11px] font-semibold text-slate-500 uppercase tracking-wider">
|
|
||||||
{isEn ? "METAR Settlement (30m) · Daily High" : `${metarHeaderLabel} · 当日最高`}
|
|
||||||
</span>
|
|
||||||
<span className="text-2xl font-bold font-mono text-blue-600 mt-1">
|
|
||||||
{temp(observedHighMetar)}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="hidden sm:flex flex-col items-end text-right">
|
const timeframeActions = (
|
||||||
<span className="text-[10px] text-slate-400 uppercase font-semibold">
|
<div className="flex items-center gap-1 rounded bg-[#eef2f6] p-0.5 border border-slate-200">
|
||||||
{isEn ? "Daily Peak" : "当日最高气温"}
|
{(["1D", "3D", "5D", "7D"] as const).map((tf) => (
|
||||||
</span>
|
<button
|
||||||
<div className="mt-1 flex items-center gap-2 text-xs font-mono text-slate-600">
|
key={tf}
|
||||||
<span>{isEn ? "Runway" : runwayHighLabel}: <strong className="text-[#009688]">{temp(observedHighRunway)}</strong></span>
|
type="button"
|
||||||
<span>|</span>
|
onClick={() => setTimeframe(tf)}
|
||||||
<span>{isEn ? "METAR" : metarHighLabel}: <strong className="text-blue-600">{temp(observedHighMetar)}</strong></span>
|
className={clsx(
|
||||||
{wundergroundDailyHigh !== null && (
|
"px-2 py-0.5 text-[9px] font-bold rounded transition-all",
|
||||||
|
timeframe === tf
|
||||||
|
? "bg-white text-blue-600 shadow-sm border border-slate-200/50"
|
||||||
|
: "text-slate-500 hover:text-slate-800"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{tf}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Panel title={panelTitle} actions={timeframeActions}>
|
||||||
|
<div className="flex h-full min-h-[300px] flex-col">
|
||||||
|
{/* Compact stats bar */}
|
||||||
|
{compact ? (
|
||||||
|
<div className="shrink-0 border-b border-slate-200 bg-white px-3 py-1.5 flex items-center justify-between">
|
||||||
|
{timeframe === "1D" ? (
|
||||||
|
<div className="flex items-center gap-4 text-[11px]">
|
||||||
|
<span className="font-semibold text-slate-500">
|
||||||
|
{isEn ? "Runway" : runwayHeaderLabel}:{" "}
|
||||||
|
<strong className="text-[#009688] font-mono">{temp(currentRunwayTemp)}</strong>
|
||||||
|
</span>
|
||||||
|
<span className="text-slate-300">|</span>
|
||||||
|
<span className="font-semibold text-slate-500">
|
||||||
|
{isEn ? "METAR" : metarHeaderLabel}:{" "}
|
||||||
|
<strong className="text-blue-600 font-mono">{temp(observedHighMetar)}</strong>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="flex items-center gap-4 text-[11px]">
|
||||||
|
<span className="font-semibold text-slate-500">
|
||||||
|
DEB: <strong className="text-orange-600 font-mono">{temp(debVal)}</strong>
|
||||||
|
</span>
|
||||||
|
{modelMin !== null && modelMax !== null && (
|
||||||
<>
|
<>
|
||||||
<span>|</span>
|
<span className="text-slate-300">|</span>
|
||||||
<span>WU: <strong className="text-purple-600">{temp(wundergroundDailyHigh)}</strong></span>
|
<span className="font-semibold text-slate-500">
|
||||||
|
{isEn ? "Models" : "多模型"}:{" "}
|
||||||
|
<strong className="text-slate-700 font-mono">
|
||||||
|
{temp(modelMin)} - {temp(modelMax)}
|
||||||
|
</strong>
|
||||||
|
</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="text-[10px] text-slate-400 font-mono">
|
||||||
|
{timeframe === "1D" && formattedUpdateTime.includes(" ") ? formattedUpdateTime.split(" ")[1].slice(0, 5) : ""}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
/* Normal detailed stats bar */
|
||||||
|
<div className="shrink-0 border-b border-slate-200 bg-white px-4 py-3">
|
||||||
|
{/* Top Row: Large temperatures */}
|
||||||
|
<div className="flex justify-between items-center gap-6 mb-3">
|
||||||
|
{timeframe === "1D" ? (
|
||||||
|
<div className="flex items-center gap-12">
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="text-[11px] font-semibold text-slate-500 uppercase tracking-wider">
|
||||||
|
{isEn ? "Runway Live (1m)" : `${runwayHeaderLabel}`}
|
||||||
|
</span>
|
||||||
|
<span className="text-2xl font-bold font-mono text-[#009688] mt-1">
|
||||||
|
{temp(currentRunwayTemp)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="text-[11px] font-semibold text-slate-500 uppercase tracking-wider">
|
||||||
|
{isEn ? "METAR Settlement (30m) · Daily High" : `${metarHeaderLabel} · 当日最高`}
|
||||||
|
</span>
|
||||||
|
<span className="text-2xl font-bold font-mono text-blue-600 mt-1">
|
||||||
|
{temp(observedHighMetar)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="flex items-center gap-12">
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="text-[11px] font-semibold text-slate-500 uppercase tracking-wider">
|
||||||
|
DEB Max
|
||||||
|
</span>
|
||||||
|
<span className="text-2xl font-bold font-mono text-orange-600 mt-1">
|
||||||
|
{temp(debVal)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="text-[11px] font-semibold text-slate-500 uppercase tracking-wider">
|
||||||
|
{isEn ? "Model Range" : "多模型区间"}
|
||||||
|
</span>
|
||||||
|
<span className="text-2xl font-bold font-mono text-slate-700 mt-1">
|
||||||
|
{modelMin !== null && modelMax !== null ? `${temp(modelMin)} - ${temp(modelMax)}` : "--"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Bottom Row: Model Range Panel */}
|
<div className="hidden sm:flex flex-col items-end text-right">
|
||||||
<div className="grid grid-cols-4 gap-4 border-t border-slate-100 pt-3 text-xs font-mono text-slate-700 bg-slate-50/50 -mx-4 px-4 rounded-b-md">
|
<span className="text-[10px] text-slate-400 uppercase font-semibold">
|
||||||
<div className="flex flex-col gap-0.5">
|
{isEn ? "Daily Peak" : "当日最高气温"}
|
||||||
<span className="text-[10px] text-slate-400 uppercase font-semibold">
|
</span>
|
||||||
{isEn ? "Model Range" : "模型区间"}
|
<div className="mt-1 flex items-center gap-2 text-xs font-mono text-slate-600">
|
||||||
</span>
|
<span>{isEn ? "Runway" : runwayHighLabel}: <strong className="text-[#009688]">{temp(observedHighRunway)}</strong></span>
|
||||||
<strong className="text-slate-800 font-bold">
|
<span>|</span>
|
||||||
{modelMin !== null && modelMax !== null ? `${temp(modelMin)} - ${temp(modelMax)}` : "--"}
|
<span>{isEn ? "METAR" : metarHighLabel}: <strong className="text-blue-600">{temp(observedHighMetar)}</strong></span>
|
||||||
</strong>
|
{wundergroundDailyHigh !== null && (
|
||||||
</div>
|
<>
|
||||||
<div className="flex flex-col gap-0.5">
|
<span>|</span>
|
||||||
<span className="text-[10px] text-slate-400 uppercase font-semibold">
|
<span>WU: <strong className="text-purple-600">{temp(wundergroundDailyHigh)}</strong></span>
|
||||||
DEB
|
</>
|
||||||
</span>
|
)}
|
||||||
<strong className="text-blue-600 font-bold">
|
</div>
|
||||||
{temp(debVal)}
|
</div>
|
||||||
</strong>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-col gap-0.5">
|
|
||||||
<span className="text-[10px] text-slate-400 uppercase font-semibold">
|
|
||||||
{isEn ? "Spread" : "分歧"}
|
|
||||||
</span>
|
|
||||||
<strong className={clsx("font-bold", spreadLabel === "高分歧" ? "text-amber-600" : "text-slate-600")}>
|
|
||||||
{spread !== null ? `${spread.toFixed(1)}°C` : "--"}
|
|
||||||
{spreadLabel && ` · ${isEn ? spreadLabelEn : spreadLabel}`}
|
|
||||||
</strong>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-col gap-0.5">
|
|
||||||
<span className="text-[10px] text-slate-400 uppercase font-semibold">
|
|
||||||
{isEn ? "Updated" : "更新时间"}
|
|
||||||
</span>
|
|
||||||
<strong className="text-slate-800 font-bold">
|
|
||||||
{formattedUpdateTime}
|
|
||||||
</strong>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Bottom Row: Model Range Panel (Only for 1D mode) */}
|
||||||
|
{timeframe === "1D" && (
|
||||||
|
<div className="grid grid-cols-4 gap-4 border-t border-slate-100 pt-3 text-xs font-mono text-slate-700 bg-slate-50/50 -mx-4 px-4 rounded-b-md">
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
|
<span className="text-[10px] text-slate-400 uppercase font-semibold">
|
||||||
|
{isEn ? "Model Range" : "模型区间"}
|
||||||
|
</span>
|
||||||
|
<strong className="text-slate-800 font-bold">
|
||||||
|
{modelMin !== null && modelMax !== null ? `${temp(modelMin)} - ${temp(modelMax)}` : "--"}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
|
<span className="text-[10px] text-slate-400 uppercase font-semibold">
|
||||||
|
DEB
|
||||||
|
</span>
|
||||||
|
<strong className="text-blue-600 font-bold">
|
||||||
|
{temp(debVal)}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
|
<span className="text-[10px] text-slate-400 uppercase font-semibold">
|
||||||
|
{isEn ? "Spread" : "分歧"}
|
||||||
|
</span>
|
||||||
|
<strong className={clsx("font-bold", spreadLabel === "高分歧" ? "text-amber-600" : "text-slate-600")}>
|
||||||
|
{spread !== null ? `${spread.toFixed(1)}°C` : "--"}
|
||||||
|
{spreadLabel && ` · ${isEn ? spreadLabelEn : spreadLabel}`}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
|
<span className="text-[10px] text-slate-400 uppercase font-semibold">
|
||||||
|
{isEn ? "Updated" : "更新时间"}
|
||||||
|
</span>
|
||||||
|
<strong className="text-slate-800 font-bold">
|
||||||
|
{formattedUpdateTime}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
|
|
||||||
{/* Runway observations */}
|
{/* Runway observations (Only for 1D mode and when not compact) */}
|
||||||
{runwayPlates.length > 0 && (
|
{timeframe === "1D" && !compact && runwayPlates.length > 0 && (
|
||||||
<div className="shrink-0 border-b border-slate-200 bg-[#f8fafc] px-3 py-2">
|
<div className="shrink-0 border-b border-slate-200 bg-[#f8fafc] px-3 py-2">
|
||||||
<div className="flex items-center justify-between text-[11px] font-black text-slate-700 mb-1.5 uppercase">
|
<div className="flex items-center justify-between text-[11px] font-black text-slate-700 mb-1.5 uppercase">
|
||||||
<span>{isEn ? "Runway Observations" : "跑道观测"}</span>
|
<span>{isEn ? "Runway Observations" : "跑道观测"}</span>
|
||||||
@@ -898,8 +1232,8 @@ export function LiveTemperatureThresholdChart({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Multi-model list (only when runway data is on chart) */}
|
{/* Multi-model list (Only in 1D mode and when not compact) */}
|
||||||
{hasRunwayData && series.some((s) => s.key.startsWith("model_curve_")) && (
|
{timeframe === "1D" && !compact && hasRunwayData && series.some((s) => s.key.startsWith("model_curve_")) && (
|
||||||
<div className="shrink-0 border-b border-slate-200 bg-white px-4 py-2">
|
<div className="shrink-0 border-b border-slate-200 bg-white px-4 py-2">
|
||||||
<div className="flex flex-wrap gap-x-6 gap-y-1 text-[11px]">
|
<div className="flex flex-wrap gap-x-6 gap-y-1 text-[11px]">
|
||||||
<span className="font-black text-slate-500 uppercase mr-2">
|
<span className="font-black text-slate-500 uppercase mr-2">
|
||||||
@@ -923,11 +1257,8 @@ export function LiveTemperatureThresholdChart({
|
|||||||
|
|
||||||
{/* Chart */}
|
{/* Chart */}
|
||||||
<div className="relative min-h-0 flex-1 p-2">
|
<div className="relative min-h-0 flex-1 p-2">
|
||||||
<div className="absolute left-3 top-3 z-10 rounded border border-slate-200 bg-white px-2 py-1 text-[11px] font-black text-slate-800 shadow-sm">
|
|
||||||
{row ? rowName(row) : ""}
|
|
||||||
</div>
|
|
||||||
{/* Interactive legend */}
|
{/* Interactive legend */}
|
||||||
<div className="flex flex-wrap gap-x-4 gap-y-1 px-3 py-1.5 text-[11px] border-b border-slate-200 bg-white">
|
<div className="flex flex-wrap gap-x-4 gap-y-1 px-3 py-1.5 text-[11px] border-b border-[#e2e8f0] bg-white">
|
||||||
{chartSeries.length > 1 && chartSeries.map((s) => (
|
{chartSeries.length > 1 && chartSeries.map((s) => (
|
||||||
<button
|
<button
|
||||||
key={s.key}
|
key={s.key}
|
||||||
@@ -951,25 +1282,25 @@ export function LiveTemperatureThresholdChart({
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<ReLineChart data={data} margin={{ top: 16, right: 44, left: 4, bottom: 8 }}>
|
<ReLineChart data={data} margin={{ top: 16, right: compact ? 20 : 44, left: 4, bottom: 8 }}>
|
||||||
<CartesianGrid stroke="#dbe6ef" strokeDasharray="2 2" />
|
<CartesianGrid stroke="#dbe6ef" strokeDasharray="2 2" />
|
||||||
<XAxis
|
<XAxis
|
||||||
dataKey="label"
|
dataKey="label"
|
||||||
tick={{ fontSize: 10, fill: "#64748b" }}
|
tick={{ fontSize: 9, fill: "#64748b" }}
|
||||||
tickLine={false}
|
tickLine={false}
|
||||||
axisLine={{ stroke: "#cbd5e1" }}
|
axisLine={{ stroke: "#cbd5e1" }}
|
||||||
interval={Math.max(1, Math.floor(data.length / 8))}
|
interval={Math.max(1, Math.floor(data.length / (compact ? 6 : 10)))}
|
||||||
/>
|
/>
|
||||||
<YAxis
|
<YAxis
|
||||||
orientation="right"
|
orientation="right"
|
||||||
tick={{ fontSize: 10, fill: "#64748b" }}
|
tick={{ fontSize: 9, fill: "#64748b" }}
|
||||||
tickFormatter={(v) => `${Number(v).toFixed(0)}°`}
|
tickFormatter={(v) => `${Number(v).toFixed(0)}°`}
|
||||||
axisLine={{ stroke: "#cbd5e1" }}
|
axisLine={{ stroke: "#cbd5e1" }}
|
||||||
tickLine={false}
|
tickLine={false}
|
||||||
domain={chartDomain}
|
domain={chartDomain}
|
||||||
ticks={intDegreeTicks ?? undefined}
|
ticks={intDegreeTicks ?? undefined}
|
||||||
/>
|
/>
|
||||||
{cityThresholds.map((t, idx) => {
|
{timeframe === "1D" && cityThresholds.map((t, idx) => {
|
||||||
const isSelected = row && (Number(row.target_threshold ?? row.target_value) === t.threshold);
|
const isSelected = row && (Number(row.target_threshold ?? row.target_value) === t.threshold);
|
||||||
const labelText = isEn
|
const labelText = isEn
|
||||||
? `${t.kind === "gte" ? "≥" : "≤"} ${t.threshold.toFixed(1)}° [${t.isBreached ? "Excluded" : "Active"}]`
|
? `${t.kind === "gte" ? "≥" : "≤"} ${t.threshold.toFixed(1)}° [${t.isBreached ? "Excluded" : "Active"}]`
|
||||||
@@ -983,7 +1314,7 @@ export function LiveTemperatureThresholdChart({
|
|||||||
strokeDasharray={isSelected ? undefined : "4 4"}
|
strokeDasharray={isSelected ? undefined : "4 4"}
|
||||||
strokeWidth={isSelected ? 2 : 1}
|
strokeWidth={isSelected ? 2 : 1}
|
||||||
label={{
|
label={{
|
||||||
value: labelText,
|
value: compact ? undefined : labelText,
|
||||||
fill: isSelected ? "#3b82f6" : t.isBreached ? "#ef4444" : "#f97316",
|
fill: isSelected ? "#3b82f6" : t.isBreached ? "#ef4444" : "#f97316",
|
||||||
fontSize: 9,
|
fontSize: 9,
|
||||||
position: isSelected ? "left" : "insideBottomRight",
|
position: isSelected ? "left" : "insideBottomRight",
|
||||||
@@ -1007,23 +1338,25 @@ export function LiveTemperatureThresholdChart({
|
|||||||
dataKey={item.key}
|
dataKey={item.key}
|
||||||
name={item.label}
|
name={item.label}
|
||||||
stroke={item.color}
|
stroke={item.color}
|
||||||
strokeWidth={item.featured ? 2 : 1}
|
strokeWidth={item.featured ? 2 : 1.2}
|
||||||
strokeDasharray={item.dashed ? "4 3" : undefined}
|
strokeDasharray={item.dashed ? "4 3" : undefined}
|
||||||
dot={false}
|
dot={timeframe === "5D" || timeframe === "7D"}
|
||||||
activeDot={{ r: item.featured ? 5 : 4 }}
|
activeDot={{ r: item.featured ? 5 : 4 }}
|
||||||
connectNulls={true}
|
connectNulls={true}
|
||||||
isAnimationActive={false}
|
isAnimationActive={false}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<Brush
|
{!compact && (timeframe === "1D" || timeframe === "3D") && (
|
||||||
dataKey="label"
|
<Brush
|
||||||
height={20}
|
dataKey="label"
|
||||||
stroke="#64748b"
|
height={18}
|
||||||
fill="#f8fafc"
|
stroke="#64748b"
|
||||||
travellerWidth={8}
|
fill="#f8fafc"
|
||||||
startIndex={0}
|
travellerWidth={8}
|
||||||
endIndex={data.length - 1}
|
startIndex={0}
|
||||||
/>
|
endIndex={data.length - 1}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</ReLineChart>
|
</ReLineChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -260,7 +260,6 @@ async function getTerminal({
|
|||||||
time_range: "today",
|
time_range: "today",
|
||||||
limit: "180",
|
limit: "180",
|
||||||
force_refresh: String(forceRefresh),
|
force_refresh: String(forceRefresh),
|
||||||
skip_polymarket: "true",
|
|
||||||
});
|
});
|
||||||
if (tradingRegion && tradingRegion !== "all") {
|
if (tradingRegion && tradingRegion !== "all") {
|
||||||
params.set("trading_region", tradingRegion);
|
params.set("trading_region", tradingRegion);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ async def scan_terminal(
|
|||||||
force_refresh: bool = False,
|
force_refresh: bool = False,
|
||||||
region: str = "",
|
region: str = "",
|
||||||
trading_region: str = "",
|
trading_region: str = "",
|
||||||
skip_polymarket: bool = False,
|
|
||||||
timezone_offset_seconds: int | None = None,
|
timezone_offset_seconds: int | None = None,
|
||||||
):
|
):
|
||||||
return await get_scan_terminal_payload(
|
return await get_scan_terminal_payload(
|
||||||
@@ -46,7 +45,6 @@ async def scan_terminal(
|
|||||||
limit=limit,
|
limit=limit,
|
||||||
force_refresh=force_refresh,
|
force_refresh=force_refresh,
|
||||||
region=region or trading_region or None,
|
region=region or trading_region or None,
|
||||||
skip_polymarket=skip_polymarket,
|
|
||||||
timezone_offset_seconds=timezone_offset_seconds,
|
timezone_offset_seconds=timezone_offset_seconds,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ def normalize_scan_terminal_filters(
|
|||||||
or "today",
|
or "today",
|
||||||
"limit": max(1, min(safe_int(raw.get("limit"), 25), 200)),
|
"limit": max(1, min(safe_int(raw.get("limit"), 25), 200)),
|
||||||
"max_spread": max(0.0, _safe_float(raw.get("max_spread")) or 0.03),
|
"max_spread": max(0.0, _safe_float(raw.get("max_spread")) or 0.03),
|
||||||
"skip_polymarket": str(raw.get("skip_polymarket") or "false").lower()
|
|
||||||
in {"1", "true", "yes", "on"},
|
in {"1", "true", "yes", "on"},
|
||||||
}
|
}
|
||||||
trading_region = str(raw.get("trading_region") or "").strip().lower()
|
trading_region = str(raw.get("trading_region") or "").strip().lower()
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ async def get_scan_terminal_payload(
|
|||||||
limit: int = 25,
|
limit: int = 25,
|
||||||
force_refresh: bool = False,
|
force_refresh: bool = False,
|
||||||
region: str = "",
|
region: str = "",
|
||||||
skip_polymarket: bool = False,
|
|
||||||
timezone_offset_seconds: int | None = None,
|
timezone_offset_seconds: int | None = None,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
legacy_routes._assert_entitlement(request)
|
legacy_routes._assert_entitlement(request)
|
||||||
@@ -61,7 +60,6 @@ async def get_scan_terminal_payload(
|
|||||||
"market_type": market_type,
|
"market_type": market_type,
|
||||||
"time_range": time_range,
|
"time_range": time_range,
|
||||||
"limit": limit,
|
"limit": limit,
|
||||||
"skip_polymarket": skip_polymarket,
|
|
||||||
}
|
}
|
||||||
if timezone_offset_seconds is not None:
|
if timezone_offset_seconds is not None:
|
||||||
filters["timezone_offset_seconds"] = timezone_offset_seconds
|
filters["timezone_offset_seconds"] = timezone_offset_seconds
|
||||||
|
|||||||
Reference in New Issue
Block a user