feat: implement AI city forecast streaming hook and utility functions for scan terminal
This commit is contained in:
@@ -281,14 +281,7 @@ export function pickMarketBucketForWeatherCenter(
|
|||||||
}
|
}
|
||||||
if (roundedMatch) return roundedMatch;
|
if (roundedMatch) return roundedMatch;
|
||||||
if (!nearest) return isReasonableFallback(selectedBucket) ? selectedBucket : null;
|
if (!nearest) return isReasonableFallback(selectedBucket) ? selectedBucket : null;
|
||||||
const comparable = normalizeMarketComparableTemp(expectedHigh, tempSymbol, nearest);
|
if (Number.isFinite(nearestDelta) && isReasonableFallback(nearest)) {
|
||||||
const unit = String(nearest.unit || "").toUpperCase();
|
|
||||||
const maxReasonableDelta = unit === "F" ? 16 : 8;
|
|
||||||
if (
|
|
||||||
comparable != null &&
|
|
||||||
Number.isFinite(nearestDelta) &&
|
|
||||||
nearestDelta <= maxReasonableDelta
|
|
||||||
) {
|
|
||||||
return nearest;
|
return nearest;
|
||||||
}
|
}
|
||||||
return isReasonableFallback(selectedBucket) ? selectedBucket : null;
|
return isReasonableFallback(selectedBucket) ? selectedBucket : null;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { normalizeCityKey } from "./decision-utils";
|
|||||||
|
|
||||||
const AI_CITY_FORECAST_CACHE_PREFIX = "polyWeather_aiCityForecast_v3";
|
const AI_CITY_FORECAST_CACHE_PREFIX = "polyWeather_aiCityForecast_v3";
|
||||||
const AI_CITY_FORECAST_CACHE_TTL_MS = 60 * 60 * 1000;
|
const AI_CITY_FORECAST_CACHE_TTL_MS = 60 * 60 * 1000;
|
||||||
const CITY_MARKET_SCAN_CACHE_PREFIX = "polyWeather_cityMarketScan_v2";
|
const CITY_MARKET_SCAN_CACHE_PREFIX = "polyWeather_cityMarketScan_v3";
|
||||||
const CITY_MARKET_SCAN_CACHE_TTL_MS = 10 * 60 * 1000;
|
const CITY_MARKET_SCAN_CACHE_TTL_MS = 10 * 60 * 1000;
|
||||||
const pendingAiCityForecastRequests = new Map<
|
const pendingAiCityForecastRequests = new Map<
|
||||||
string,
|
string,
|
||||||
@@ -504,7 +504,7 @@ export function useCityMarketScan({
|
|||||||
const cacheKey = buildStorageKey(CITY_MARKET_SCAN_CACHE_PREFIX, [
|
const cacheKey = buildStorageKey(CITY_MARKET_SCAN_CACHE_PREFIX, [
|
||||||
normalizeCityKey(detailCityName),
|
normalizeCityKey(detailCityName),
|
||||||
detail.local_date || "",
|
detail.local_date || "",
|
||||||
"lite",
|
"full",
|
||||||
]);
|
]);
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
if (detail.market_scan) {
|
if (detail.market_scan) {
|
||||||
|
|||||||
Reference in New Issue
Block a user