|
9 | 9 |
|
10 | 10 | from models.article import Article |
11 | 11 | from services import article_service |
12 | | -from services.pricing_service import fetch_card_prices |
13 | | - |
14 | 12 | Period = Literal["daily", "weekly", "monthly"] |
15 | 13 |
|
16 | 14 |
|
@@ -88,7 +86,6 @@ def compute_dashboard_stats( |
88 | 86 | db: Session, |
89 | 87 | user_id: int, |
90 | 88 | *, |
91 | | - include_market: bool = False, |
92 | 89 | range_start: dt.datetime | None = None, |
93 | 90 | range_end: dt.datetime | None = None, |
94 | 91 | period: Period = "daily", |
@@ -168,10 +165,10 @@ def in_range(a: Article) -> bool: |
168 | 165 | if p is not None |
169 | 166 | ) |
170 | 167 |
|
171 | | - top_profitable = sorted(sold, key=_profit_eur, reverse=True)[:5] |
| 168 | + top_profitable = sorted(sold, key=_profit_eur, reverse=True) |
172 | 169 | with_duration = [(a, _hours_to_sell(a)) for a in sold] |
173 | 170 | with_duration = [(a, h) for a, h in with_duration if h is not None] |
174 | | - fastest = sorted(with_duration, key=lambda x: x[1])[:5] |
| 171 | + fastest = sorted(with_duration, key=lambda x: x[1]) |
175 | 172 |
|
176 | 173 | unsold = [a for a in rows if not a.is_sold] |
177 | 174 | inventory_count = len(unsold) |
@@ -227,25 +224,6 @@ def in_range(a: Article) -> bool: |
227 | 224 | } |
228 | 225 | ) |
229 | 226 |
|
230 | | - market_sum: float | None = None |
231 | | - market_sum_unsold: float | None = None |
232 | | - market_errors = 0 |
233 | | - if include_market: |
234 | | - market_sum = 0.0 |
235 | | - market_sum_unsold = 0.0 |
236 | | - for a in rows: |
237 | | - if not a.set_code or not a.card_number: |
238 | | - continue |
239 | | - p = fetch_card_prices(a.set_code, a.card_number, a.pokemon_name) |
240 | | - if p.get("error"): |
241 | | - market_errors += 1 |
242 | | - cm = p.get("cardmarket_eur") |
243 | | - if cm is not None: |
244 | | - v = float(cm) |
245 | | - market_sum += v |
246 | | - if not a.is_sold: |
247 | | - market_sum_unsold += v |
248 | | - |
249 | 227 | return { |
250 | 228 | "range": { |
251 | 229 | "start": range_start.isoformat(), |
@@ -273,11 +251,9 @@ def in_range(a: Article) -> bool: |
273 | 251 | "inventory_purchase_total_eur": round(inventory_purchase_total_eur, 2), |
274 | 252 | "inventory_sell_total_eur": round(inventory_sell_total_eur, 2), |
275 | 253 | "inventory_estimated_profit_eur": round(inventory_estimated_profit_eur, 2), |
276 | | - "estimated_cardmarket_inventory_eur": round(market_sum, 2) if market_sum is not None else None, |
277 | | - "estimated_cardmarket_unsold_eur": round(market_sum_unsold, 2) |
278 | | - if market_sum_unsold is not None |
279 | | - else None, |
280 | | - "market_lookup_errors": market_errors, |
| 254 | + "estimated_cardmarket_inventory_eur": None, |
| 255 | + "estimated_cardmarket_unsold_eur": None, |
| 256 | + "market_lookup_errors": 0, |
281 | 257 | "revenue_timeline": revenue_timeline, |
282 | 258 | "recent_sales": recent_sales_payload, |
283 | 259 | "top_profitable": [ |
|
0 commit comments