31 lines
940 B
Dart
31 lines
940 B
Dart
import '../utils/sync_run_formatters.dart';
|
|
|
|
class BackfillSyncItem {
|
|
const BackfillSyncItem({
|
|
required this.slotStart,
|
|
required this.symbols,
|
|
this.slotStartWire,
|
|
});
|
|
|
|
final DateTime slotStart;
|
|
final List<String> symbols;
|
|
|
|
/// Exact `slotStart` string from the sync-run API (Alpaca `start` param).
|
|
final String? slotStartWire;
|
|
|
|
/// Wire form for DB spot checks: `raw->>'slot_start'` and Alpaca `start`.
|
|
String get fetchSlotStartWire =>
|
|
slotStartWire ?? formatMarketHistorySlotWire(slotStart);
|
|
|
|
factory BackfillSyncItem.fromJson(Map<String, dynamic> json) {
|
|
final String slotStartRaw = json['slotStart'] as String;
|
|
return BackfillSyncItem(
|
|
slotStart: DateTime.parse(slotStartRaw).toUtc(),
|
|
slotStartWire: slotStartRaw,
|
|
symbols: (json['symbols'] as List<dynamic>? ?? <dynamic>[])
|
|
.map((dynamic value) => value.toString())
|
|
.toList(growable: false),
|
|
);
|
|
}
|
|
}
|