fix: increment DB version and improve ads parsing robustness

This commit is contained in:
Christian Vidal Wolf
2026-01-21 10:52:30 +01:00
parent e5c72c48c5
commit 1c2a0e86aa
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -201,9 +201,9 @@ const App: React.FC = () => {
await saveAdsData(data); await saveAdsData(data);
console.log("Ads loaded:", data.length, "records from", file.name); console.log("Ads loaded:", data.length, "records from", file.name);
setIsDataModalOpen(false); setIsDataModalOpen(false);
} catch (error) { } catch (error: any) {
console.error("Failed to parse Ads file", error); console.error("Failed to parse Ads file", error);
alert("Error parsing Ads file. Please check the format."); alert(`Error parsing Ads file: ${error.message || 'Unknown error'}. Please check the format.`);
} finally { } finally {
setSyncing(false); setSyncing(false);
} }
+1 -1
View File
@@ -357,7 +357,7 @@ export const processAdsExcel = async (fileOrBuffer: File | ArrayBuffer): Promise
const arrayBuffer = fileOrBuffer instanceof File const arrayBuffer = fileOrBuffer instanceof File
? await fileOrBuffer.arrayBuffer() ? await fileOrBuffer.arrayBuffer()
: fileOrBuffer; : fileOrBuffer;
const workbook = XLSX.read(arrayBuffer); const workbook = XLSX.read(arrayBuffer, { type: 'array' });
const allData: AdsRecord[] = []; const allData: AdsRecord[] = [];
// Process ALL sheets (e.g., "2025", "2026") // Process ALL sheets (e.g., "2025", "2026")
+1 -1
View File
@@ -4,7 +4,7 @@ import { SalesRecord } from '../types';
const DB_NAME = 'CrazeAnalytixDB'; const DB_NAME = 'CrazeAnalytixDB';
const STORE_NAME = 'salesData'; const STORE_NAME = 'salesData';
const ADS_STORE_NAME = 'adsData'; const ADS_STORE_NAME = 'adsData';
const DB_VERSION = 1; const DB_VERSION = 2;
// Increment this when data processing logic changes (e.g., field mapping changes) // Increment this when data processing logic changes (e.g., field mapping changes)
// This forces cache invalidation and re-processing of CSV data // This forces cache invalidation and re-processing of CSV data
const DATA_SCHEMA_VERSION = 2; // Updated for LICENSE column mapping const DATA_SCHEMA_VERSION = 2; // Updated for LICENSE column mapping