mirror of
https://github.com/nethunterzist/trendyol-analiz
synced 2026-07-01 01:17:04 +00:00
fix(overview): en çok satış yapan ürünlerde aynı ürün varyantları tekrar gösterilmesin
Ne yaptık: - topSellingProducts useMemo'da ürün adına göre dedup eklendi - Aynı isimli ürünlerden sadece en yüksek satışlı olanı tutulur Neden yaptık: - Trendyol'da aynı ürünün farklı varyantları (renk/beden) ayrı product_id ile scrape ediliyor ama hepsinde aynı aggregate satış sayısı var - Bu yüzden 'Buharlı Temizleyici 26 Parça 2000w ultra güçlü Gri' gibi ürünler listede 3 kez aynı sayı ile görünüyordu (2, 3, 4. sıra)
This commit is contained in:
@@ -1047,19 +1047,23 @@ function ReportDashboard() {
|
||||
|
||||
// Top selling products
|
||||
const topSellingProducts = useMemo(() => {
|
||||
console.log('🏆 [TOP PRODUCTS] Calculating top selling products...')
|
||||
if (!dashboardData?.all_products) {
|
||||
console.warn('⚠️ [TOP PRODUCTS] No all_products data')
|
||||
return []
|
||||
if (!dashboardData?.all_products) return []
|
||||
|
||||
// Deduplicate by name: same product appears multiple times as different variants
|
||||
// (Trendyol reports aggregate orders for all variants, causing duplicates in rankings)
|
||||
const seen = new Map()
|
||||
for (const product of dashboardData.all_products) {
|
||||
const key = product.name?.trim()
|
||||
if (!key) continue
|
||||
const existing = seen.get(key)
|
||||
if (!existing || (product.orders || 0) > (existing.orders || 0)) {
|
||||
seen.set(key, product)
|
||||
}
|
||||
}
|
||||
|
||||
const sorted = [...dashboardData.all_products]
|
||||
return [...seen.values()]
|
||||
.sort((a, b) => (b.orders || 0) - (a.orders || 0))
|
||||
.slice(0, 10)
|
||||
|
||||
console.log('✅ [TOP PRODUCTS] Top 10 products:', sorted.length, 'items')
|
||||
console.log('📊 [TOP PRODUCTS] First product:', sorted[0])
|
||||
return sorted
|
||||
}, [dashboardData])
|
||||
|
||||
// Top selling brands
|
||||
|
||||
Reference in New Issue
Block a user