fix(data): restore pagination early-break + update test count
Code review on b977c37 flagged: with dataset smaller than limit=1000
(typical Phase 1 case), the loop made an extra HTTP request that
returned duplicate rows. Restored `if len(rows) < limit: break`
after extending. Test assertion adjusted from 2 to 1 calls.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -59,6 +59,8 @@ class OHLCVLoader:
|
||||
if not rows:
|
||||
break
|
||||
all_rows.extend(rows)
|
||||
if len(rows) < limit:
|
||||
break
|
||||
last_ts = rows[-1][0]
|
||||
new_since = last_ts + timeframe_ms
|
||||
if new_since <= since:
|
||||
|
||||
@@ -55,7 +55,7 @@ def test_loader_uses_cache_on_second_call(tmp_path: Path, mocker, sample_ohlcv_r
|
||||
df1 = loader.load(req)
|
||||
df2 = loader.load(req)
|
||||
|
||||
assert fake_exchange.fetch_ohlcv.call_count == 2 # paginazione interna, non caching
|
||||
assert fake_exchange.fetch_ohlcv.call_count == 1 # 48 < limit, single batch
|
||||
pd.testing.assert_frame_equal(df1, df2)
|
||||
# Seconda chiamata legge da cache, non chiama exchange
|
||||
fake_exchange.fetch_ohlcv.reset_mock()
|
||||
|
||||
Reference in New Issue
Block a user