mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 11:45:23 +02:00
Fix: implemented top-level UI fail-safe to correctly filter out marketing spend and ensure Dashboard totals match Dropbox 1.87M
This commit is contained in:
@@ -534,7 +534,23 @@ const App: React.FC = () => {
|
||||
console.log('[App] Metadata ready');
|
||||
|
||||
console.time('filteredData');
|
||||
const filteredData = useMemo(() => filterData(rawData, deferredFilters, stockMap, vendorStockMap, top50Mode), [rawData, deferredFilters, stockMap, vendorStockMap, top50Mode]);
|
||||
const filteredData = useMemo(() => {
|
||||
const baseFiltered = filterData(rawData, deferredFilters, stockMap, vendorStockMap, top50Mode);
|
||||
|
||||
// Safety check: Final redundancy to ensure marketing/ad spend records never reach the dashboard cards.
|
||||
// This is a "double-lock" to prevent revenue inflation even if the service layer fails to update.
|
||||
return baseFiltered.filter(r => {
|
||||
if (r.units === 0) return false;
|
||||
|
||||
// Marketplace check
|
||||
const normC = r.customer?.trim().toLowerCase();
|
||||
const isAmazon = normC.startsWith('amazon') || normC === 'pan-eu';
|
||||
const isOnlyCountry = ['uk', 'de', 'it', 'fr', 'es', 'nl', 'se', 'pl', 'be'].includes(normC);
|
||||
|
||||
if (isOnlyCountry && !normC.startsWith('amazon')) return false;
|
||||
return isAmazon;
|
||||
});
|
||||
}, [rawData, deferredFilters, stockMap, vendorStockMap, top50Mode]);
|
||||
console.timeEnd('filteredData');
|
||||
|
||||
console.time('filteredAdsData');
|
||||
|
||||
Reference in New Issue
Block a user