mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 12:35:25 +02:00
improve cpnp history restore
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { refreshSession, getStoredSession } from './auth';
|
import { refreshSession, getStoredSession } from './auth';
|
||||||
|
import { COLUMNS } from '../types';
|
||||||
|
|
||||||
const SUPABASE_URL = 'https://hwithddwaapyhnfwcesj.supabase.co';
|
const SUPABASE_URL = 'https://hwithddwaapyhnfwcesj.supabase.co';
|
||||||
const SUPABASE_ANON_KEY = 'sb_publishable_fGXkh0bSrAOqSk2jWKAzSg_NJD9YPCv';
|
const SUPABASE_ANON_KEY = 'sb_publishable_fGXkh0bSrAOqSk2jWKAzSg_NJD9YPCv';
|
||||||
@@ -323,6 +324,17 @@ export async function getHistoryDataForMerge(): Promise<Record<string, ExcelRow>
|
|||||||
for (const idx of changedIndices) {
|
for (const idx of changedIndices) {
|
||||||
target[idx] = entry.new_data?.[idx];
|
target[idx] = entry.new_data?.[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CPNP values were saved through multiple code paths over time.
|
||||||
|
// Preserve the latest non-empty value even when a given history row
|
||||||
|
// does not surface it as a changed index.
|
||||||
|
const latestCpnp =
|
||||||
|
entry.new_data?.[COLUMNS.CPNP_NO] ??
|
||||||
|
entry.old_data?.[COLUMNS.CPNP_NO];
|
||||||
|
|
||||||
|
if (latestCpnp !== undefined && latestCpnp !== null && latestCpnp !== '') {
|
||||||
|
target[COLUMNS.CPNP_NO] = latestCpnp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user