mirror of
https://github.com/nethunterzist/trendyol-analiz
synced 2026-07-03 02:07:03 +00:00
feat: tek birleştirilmiş JSON yapısına geçiş + sosyal kanıt fallback
Ne yaptık:
- data_consolidator.py: Tüm normalizasyon ve hesaplama mantığını main.py'den çıkardık
- Dashboard endpoint 1150 satırdan 25 satıra düştü (main.py -1730/+1880 net)
- Enrichment bitince otomatik konsolide dosya oluşturuluyor (report_{id}_data.json)
- Eski raporlar ilk dashboard isteğinde lazy migration ile konsolide ediliyor
- Trendyol API artık order-count döndürmediği için baskets fallback eklendi
- Inline socialProofs (scrape) > enrichment API öncelik sırası uygulandı
- Frontend KPI başlıkları orders/baskets durumuna göre dinamik değişiyor
- logging_config.py, category_seeder.py, alembic migration eklendi
- Playwright ile 9 tab test edildi, tüm veriler doğru
Neden yaptık:
- 3 farklı kaynaktan her istekte birleştirme yapılması veri tutarsızlığına ve yavaşlığa yol açıyordu
- Tek konsolide JSON dosyası ile dashboard anında yükleniyor
- Trendyol API değişikliği nedeniyle sipariş verisi kayboluyordu, baskets fallback ile çözüldü
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -245,7 +245,13 @@ def get_rating_value(product: Dict) -> float:
|
||||
rating = product.get("rating", 0)
|
||||
if isinstance(rating, dict):
|
||||
return rating.get("averageRating", 0) or 0
|
||||
return float(rating) if rating else 0
|
||||
if rating:
|
||||
return float(rating)
|
||||
# Fallback: ratingScore nested object
|
||||
rating_score = product.get("ratingScore", {})
|
||||
if isinstance(rating_score, dict):
|
||||
return float(rating_score.get("averageRating", 0) or 0)
|
||||
return 0
|
||||
|
||||
|
||||
def get_review_count(product: Dict) -> int:
|
||||
@@ -263,6 +269,11 @@ def get_review_count(product: Dict) -> int:
|
||||
rating = product.get("rating", {})
|
||||
if isinstance(rating, dict):
|
||||
review_count = rating.get("totalComments", 0) or rating.get("totalCount", 0) or 0
|
||||
if not review_count:
|
||||
# Fallback: ratingScore nested object
|
||||
rating_score = product.get("ratingScore", {})
|
||||
if isinstance(rating_score, dict):
|
||||
review_count = rating_score.get("totalCount", 0) or 0
|
||||
return int(review_count) if review_count else 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user