mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:25:22 +02:00
fix(storage): enforce Ads cached schema invalidation to clear broken numeric mapped columns
This commit is contained in:
+15
-1
@@ -7,7 +7,7 @@ const ADS_STORE_NAME = 'adsData';
|
||||
const DB_VERSION = 2;
|
||||
// Increment this when data processing logic changes (e.g., field mapping changes)
|
||||
// This forces cache invalidation and re-processing of CSV data
|
||||
const DATA_SCHEMA_VERSION = 2; // Updated for LICENSE column mapping
|
||||
const DATA_SCHEMA_VERSION = 3; // Updated to clear broken Ads data
|
||||
|
||||
const initDB = (): Promise<IDBDatabase> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -115,6 +115,7 @@ export const saveAdsData = async (data: any[]): Promise<void> => {
|
||||
|
||||
store.put(data, 'currentData');
|
||||
store.put(new Date().toISOString(), 'lastUpdated');
|
||||
store.put(DATA_SCHEMA_VERSION, 'schemaVersion');
|
||||
|
||||
transaction.oncomplete = () => resolve();
|
||||
transaction.onerror = () => reject(transaction.error);
|
||||
@@ -133,8 +134,21 @@ export const loadAdsData = async (): Promise<{ data: any[]; lastUpdated: string
|
||||
|
||||
const dataReq = store.get('currentData');
|
||||
const dateReq = store.get('lastUpdated');
|
||||
const versionReq = store.get('schemaVersion');
|
||||
|
||||
transaction.oncomplete = () => {
|
||||
const cachedVersion = versionReq.result;
|
||||
|
||||
// If schema version doesn't match, invalidate cache
|
||||
if (cachedVersion !== DATA_SCHEMA_VERSION) {
|
||||
console.log('[Storage] Ads Schema version mismatch. Cached:', cachedVersion, 'Current:', DATA_SCHEMA_VERSION);
|
||||
resolve({
|
||||
data: [],
|
||||
lastUpdated: null
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
resolve({
|
||||
data: dataReq.result || [],
|
||||
lastUpdated: dateReq.result || null
|
||||
|
||||
Reference in New Issue
Block a user