This commit is contained in:
parent
7103a0ec90
commit
de09723454
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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"),
|
||||||
|
|
|
||||||
|
|
@ -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.');
|
||||||
Loading…
Reference in New Issue