Batch scan terminal model forecasts

This commit is contained in:
2569718930@qq.com
2026-06-30 13:22:11 +08:00
parent a5f6bca527
commit 15de44767e
14 changed files with 668 additions and 134 deletions
+5 -18
View File
@@ -1,10 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
import { proxyBackendJsonGet } from "@/lib/api-proxy";
import {
buildForceRefreshProxyCachePolicy,
buildScanTerminalResponseCacheControl,
NO_STORE_CACHE_CONTROL,
} from "@/lib/proxy-cache-policy";
import { DASHBOARD_REFRESH_POLICY_SEC } from "@/lib/refresh-policy";
import {
createProxyTimer,
finishProxyTimedResponse,
@@ -12,10 +10,10 @@ import {
const API_BASE = process.env.POLYWEATHER_API_BASE_URL;
const SCAN_TERMINAL_PROXY_TIMEOUT_MS = Number(
process.env.POLYWEATHER_SCAN_TERMINAL_PROXY_TIMEOUT_MS || "35000",
process.env.POLYWEATHER_SCAN_TERMINAL_PROXY_TIMEOUT_MS || "60000",
);
export const maxDuration = 45;
export const maxDuration = 70;
export async function GET(req: NextRequest) {
const timer = createProxyTimer(req, "scan_terminal");
@@ -31,7 +29,6 @@ export async function GET(req: NextRequest) {
}
const params = new URLSearchParams();
const forceRefresh = req.nextUrl.searchParams.get("force_refresh") ?? "false";
for (const key of [
"scan_mode",
"min_price",
@@ -56,11 +53,6 @@ export async function GET(req: NextRequest) {
if (tradingRegion != null && tradingRegion !== "") {
params.set("region", tradingRegion);
}
const cachePolicy = buildForceRefreshProxyCachePolicy(
forceRefresh,
DASHBOARD_REFRESH_POLICY_SEC.scanRows,
);
const url = `${API_BASE}/api/scan/terminal?${params.toString()}`;
const controller = new AbortController();
@@ -68,15 +60,10 @@ export async function GET(req: NextRequest) {
try {
return await proxyBackendJsonGet(req, {
cacheControl: cachePolicy.responseCacheControl,
cacheControlForData: (data) =>
buildScanTerminalResponseCacheControl(
data,
cachePolicy.responseCacheControl,
),
cacheControl: NO_STORE_CACHE_CONTROL,
cacheControlForData: () => NO_STORE_CACHE_CONTROL,
fetchCache: "no-store",
publicMessage: "Failed to fetch scan terminal data",
revalidateSeconds: cachePolicy.revalidateSeconds,
includeSupabaseIdentity: true,
signal: controller.signal,
timeoutPublicMessage: "Scan terminal request timed out",