mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 11:45:23 +02:00
fix: logic to show BSR improvements (rank drops) in green
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import XLSX from 'xlsx';
|
||||
import { readFileSync } from 'fs';
|
||||
import { processAdsExcel, mergeSalesAndAdsData } from './services/dataProcessor';
|
||||
|
||||
async function run() {
|
||||
// Load ads directly
|
||||
const buf = readFileSync('/tmp/Ads-Weekly.xlsx').buffer;
|
||||
const adsData = await processAdsExcel(buf);
|
||||
|
||||
console.log('Total ads records:', adsData.length);
|
||||
|
||||
// Find INKEE ads
|
||||
const inkeeAds = adsData.filter(a => a.asin.includes('B0CQ'));
|
||||
console.log('INKEE ads rows:', inkeeAds.length);
|
||||
|
||||
if (inkeeAds.length > 0) {
|
||||
console.log('INKEE ad years:', [...new Set(inkeeAds.map(a => a.year))]);
|
||||
console.log('INKEE ad weeks:', [...new Set(inkeeAds.map(a => a.week))].sort((a, b) => a - b));
|
||||
console.log('INKEE cost sample:', inkeeAds.slice(0, 3).map(a => ({ year: a.year, week: a.week, asin: a.asin, cost: a.cost, country: a.country })));
|
||||
|
||||
// What does "DE" country map to?
|
||||
const deAds = inkeeAds.filter(a => a.country.includes('DE'));
|
||||
console.log('\nINKEE DE ads count:', deAds.length);
|
||||
if (deAds.length > 0) {
|
||||
console.log('First DE ad:', deAds[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// Now simulate merge with a mock sales record
|
||||
const mockSales = [
|
||||
{
|
||||
id: 'test', year: 2025, week: 1, asin: 'B0CQTLZRCV', customer: 'Amazon DE',
|
||||
sellOut: 500, units: 5, month: 'Jan', sku: 'TEST', title: 'INKEE', line: 'Inkee', articleName: 'INKEE'
|
||||
}
|
||||
] as any[];
|
||||
|
||||
const merged = mergeSalesAndAdsData(mockSales, adsData);
|
||||
const inkeeRow = merged.find(m => m.asin === 'B0CQTLZRCV' && m.year === 2025);
|
||||
console.log('\nMerged INKEE row:', inkeeRow ? { cost: inkeeRow.cost, salesAds: inkeeRow.salesAds, clicks: inkeeRow.clicks } : 'NOT FOUND');
|
||||
}
|
||||
|
||||
run().catch(console.error);
|
||||
Reference in New Issue
Block a user