Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/compute/derivation_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6659,7 +6659,12 @@ class DerivationEngine {
await Future<void>.delayed(const Duration(milliseconds: 250));
}
return _withRunLock(0, () async {
final days = calendarDays(sub);
// One date (every NoopIngest call): stage only that night, like the
// live path. The full walk re-staged the buffered prior evening on the
// UI isolate and then threw it away, so an import paid two nights per day.
final target = dates.length == 1 ? dates.single : null;
final days = calendarDays(sub,
targetDay: target, skipUnusedDays: target != null);
final dataNowSec = sub.lastTs ?? 0;
var done = 0;
for (var i = 0; i < days.length; i++) {
Expand Down
15 changes: 15 additions & 0 deletions test/derive_day_window_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,19 @@ void main() {
);
expect(await Future.wait([a, b]), [1, 1]);
});

// The importer hands over the prior evening plus the target date. Only the
// target is kept, so only the target night should be staged.
test('an import stages only the requested date, not the buffered evening',
() async {
final eve = DateTime(2026, 4, 24, 20).millisecondsSinceEpoch ~/ 1000;
debugSegmentedDayCount = 0;
final n = await DerivationEngine().deriveImportedDays(
_synthDay(eve, 16 * 3600),
const Profile(),
{'2026-04-25'},
);
expect(n, 1);
expect(debugSegmentedDayCount, 1);
});
}
Loading