This commit is contained in:
MarkLo127 2026-03-11 16:56:32 +08:00
parent 7103a0ec90
commit de09723454
3 changed files with 31 additions and 4 deletions

View File

@ -17,9 +17,9 @@ WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY frontend . COPY frontend .
# Accept BACKEND_URL as build argument # Accept NEXT_PUBLIC_API_URL as build argument
ARG BACKEND_URL ARG NEXT_PUBLIC_API_URL
ENV BACKEND_URL=${BACKEND_URL} ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
# Build Next.js app # Build Next.js app
RUN bun run build RUN bun run build

View File

@ -41,6 +41,8 @@ import {
getReportsByMarketType, getReportsByMarketType,
deleteReport, deleteReport,
getReportCountByMarketType, getReportCountByMarketType,
deleteReports,
getAllReports,
type SavedReport, type SavedReport,
} from "@/lib/reports-db"; } from "@/lib/reports-db";
import { import {
@ -440,7 +442,30 @@ export default function HistoryPage() {
hasAutoSyncedRef.current = true; hasAutoSyncedRef.current = true;
try { try {
// Get all local reports // First auto-clean local duplicates that might exist from older flawed versions
try {
const allLocal = await getAllReports();
const seenSignatures = new Set<string>();
const idsToDelete: number[] = [];
for (const report of allLocal) {
const signature = getReportSignature(report as any);
if (seenSignatures.has(signature)) {
if (report.id) idsToDelete.push(report.id);
} else {
seenSignatures.add(signature);
}
}
if (idsToDelete.length > 0) {
console.log(`🧹 Found ${idsToDelete.length} duplicate local reports from flawed storage, cleaning them up...`);
await deleteReports(idsToDelete);
}
} catch (err) {
console.error("Failed to cleanup local duplicates:", err);
}
// Get all local reports (re-fetch after cleanup)
const [usLocal, twseLocal, tpexLocal] = await Promise.all([ const [usLocal, twseLocal, tpexLocal] = await Promise.all([
getReportsByMarketType("us"), getReportsByMarketType("us"),
getReportsByMarketType("twse"), getReportsByMarketType("twse"),

View File

@ -0,0 +1,2 @@
// Script to clear IndexedDB duplicate records from user's Chrome
console.log('To clear duplicate reports, the user needs to clear IndexedDB or we can add a cleanup script to the app.');