This version of Antigravity is no longer supported. Please upgrade to receive the latest features.
This commit is contained in:
@@ -24,11 +24,15 @@ export async function GET(
|
|||||||
|
|
||||||
const { name } = await context.params;
|
const { name } = await context.params;
|
||||||
const forceRefresh = req.nextUrl.searchParams.get("force_refresh") ?? "false";
|
const forceRefresh = req.nextUrl.searchParams.get("force_refresh") ?? "false";
|
||||||
|
const depth = req.nextUrl.searchParams.get("depth");
|
||||||
const marketSlug = req.nextUrl.searchParams.get("market_slug");
|
const marketSlug = req.nextUrl.searchParams.get("market_slug");
|
||||||
const targetDate = req.nextUrl.searchParams.get("target_date");
|
const targetDate = req.nextUrl.searchParams.get("target_date");
|
||||||
const searchParams = new URLSearchParams({
|
const searchParams = new URLSearchParams({
|
||||||
force_refresh: forceRefresh,
|
force_refresh: forceRefresh,
|
||||||
});
|
});
|
||||||
|
if (depth) {
|
||||||
|
searchParams.set("depth", depth);
|
||||||
|
}
|
||||||
if (marketSlug) {
|
if (marketSlug) {
|
||||||
searchParams.set("market_slug", marketSlug);
|
searchParams.set("market_slug", marketSlug);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,15 @@ export function countDetailForecastDays(detail?: CityDetail | null) {
|
|||||||
export function isFullEnoughForDeepAnalysis(detail?: CityDetail | null) {
|
export function isFullEnoughForDeepAnalysis(detail?: CityDetail | null) {
|
||||||
if (!detail) return false;
|
if (!detail) return false;
|
||||||
if (detail.detail_depth && detail.detail_depth !== "full") return false;
|
if (detail.detail_depth && detail.detail_depth !== "full") return false;
|
||||||
|
const hourlyTimes = Array.isArray(detail.hourly?.times)
|
||||||
|
? detail.hourly?.times || []
|
||||||
|
: [];
|
||||||
|
const hourlyTemps = Array.isArray(detail.hourly?.temps)
|
||||||
|
? detail.hourly?.temps || []
|
||||||
|
: [];
|
||||||
|
if (!detail.local_time || hourlyTimes.length === 0 || hourlyTemps.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
countDetailModels(detail, detail.local_date) > 1 &&
|
countDetailModels(detail, detail.local_date) > 1 &&
|
||||||
countDetailForecastDays(detail) > 1
|
countDetailForecastDays(detail) > 1
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ type TerminalQueryOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type CityDetailQueryOptions = {
|
type CityDetailQueryOptions = {
|
||||||
|
depth?: "panel" | "market" | "nearby" | "full";
|
||||||
forceRefresh?: boolean;
|
forceRefresh?: boolean;
|
||||||
marketSlug?: string | null;
|
marketSlug?: string | null;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
@@ -273,6 +274,7 @@ async function getTerminal({
|
|||||||
|
|
||||||
async function getCityDetail(city: string, options: CityDetailQueryOptions = {}) {
|
async function getCityDetail(city: string, options: CityDetailQueryOptions = {}) {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
|
depth: options.depth || "full",
|
||||||
force_refresh: String(options.forceRefresh ?? false),
|
force_refresh: String(options.forceRefresh ?? false),
|
||||||
});
|
});
|
||||||
if (options.marketSlug) params.set("market_slug", options.marketSlug);
|
if (options.marketSlug) params.set("market_slug", options.marketSlug);
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ function buildCalibratedFuturePath({
|
|||||||
currentMinutes: number | null;
|
currentMinutes: number | null;
|
||||||
reversionMinutes?: number | null;
|
reversionMinutes?: number | null;
|
||||||
}) {
|
}) {
|
||||||
if (currentMinutes == null || !times.length || !observations.length) {
|
if (!times.length || !observations.length) {
|
||||||
return {
|
return {
|
||||||
adjustmentDelta: null as number | null,
|
adjustmentDelta: null as number | null,
|
||||||
future: new Array(times.length).fill(null) as Array<number | null>,
|
future: new Array(times.length).fill(null) as Array<number | null>,
|
||||||
@@ -151,15 +151,21 @@ function buildCalibratedFuturePath({
|
|||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
|
if (latestObservationMinute == null && currentMinutes == null) {
|
||||||
|
return {
|
||||||
|
adjustmentDelta: null as number | null,
|
||||||
|
future: new Array(times.length).fill(null) as Array<number | null>,
|
||||||
|
};
|
||||||
|
}
|
||||||
// In practice the backend `local_time` can lag the latest METAR/official
|
// In practice the backend `local_time` can lag the latest METAR/official
|
||||||
// observation by one refresh cycle. Anchor the future line to the newest
|
// observation by one refresh cycle. Anchor the future line to the newest
|
||||||
// observation when it is newer, otherwise the "no future obs" guard can
|
// observation when it is newer, otherwise the "no future obs" guard can
|
||||||
// suppress the calibrated path even though the user already sees a fresh
|
// suppress the calibrated path even though the user already sees a fresh
|
||||||
// green observation point on the chart.
|
// green observation point on the chart.
|
||||||
const pathStartMinutes =
|
const pathStartMinutes =
|
||||||
latestObservationMinute != null
|
latestObservationMinute == null || currentMinutes == null
|
||||||
? Math.max(currentMinutes, latestObservationMinute)
|
? latestObservationMinute ?? currentMinutes ?? 0
|
||||||
: currentMinutes;
|
: Math.max(currentMinutes, latestObservationMinute);
|
||||||
|
|
||||||
const deltas = normalizedObservations
|
const deltas = normalizedObservations
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user