143 lines
3.7 KiB
Dart
143 lines
3.7 KiB
Dart
import 'package:cyberhybridhub_server/trading/backfill_sync_item.dart';
|
|
import 'package:cyberhybridhub_server/trading/market_history_admin_logic.dart';
|
|
|
|
AdminSyncRunRecord adminSyncRun({
|
|
required int id,
|
|
required String kind,
|
|
required DateTime startedAt,
|
|
DateTime? finishedAt,
|
|
int rowsWritten = 0,
|
|
int rowsRemoved = 0,
|
|
int slotsSynced = 0,
|
|
List<BackfillSyncItem>? backfillItems,
|
|
String? error,
|
|
}) {
|
|
return AdminSyncRunRecord(
|
|
id: id,
|
|
kind: kind,
|
|
startedAt: startedAt,
|
|
finishedAt: finishedAt,
|
|
rowsWritten: rowsWritten,
|
|
rowsRemoved: rowsRemoved,
|
|
slotsSynced: slotsSynced,
|
|
backfillItems: backfillItems ?? const <BackfillSyncItem>[],
|
|
error: error,
|
|
);
|
|
}
|
|
|
|
List<AdminSyncRunRecord> fixtureAllSuccessRecentFirst(DateTime base) {
|
|
return <AdminSyncRunRecord>[
|
|
adminSyncRun(
|
|
id: 3,
|
|
kind: 'cleanup',
|
|
startedAt: base,
|
|
finishedAt: base.add(const Duration(minutes: 1)),
|
|
rowsRemoved: 100,
|
|
),
|
|
adminSyncRun(
|
|
id: 2,
|
|
kind: 'backfill',
|
|
startedAt: base.subtract(const Duration(hours: 1)),
|
|
finishedAt: base.subtract(const Duration(minutes: 59)),
|
|
rowsWritten: 500,
|
|
),
|
|
adminSyncRun(
|
|
id: 1,
|
|
kind: 'universe',
|
|
startedAt: base.subtract(const Duration(hours: 2)),
|
|
finishedAt: base.subtract(const Duration(hours: 1, minutes: 59)),
|
|
rowsWritten: 8000,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<AdminSyncRunRecord> fixtureRateLimitUnresolved(DateTime base) {
|
|
return <AdminSyncRunRecord>[
|
|
adminSyncRun(
|
|
id: 10,
|
|
kind: 'backfill',
|
|
startedAt: base,
|
|
finishedAt: base.add(const Duration(minutes: 2)),
|
|
rowsWritten: 0,
|
|
error: 'AlpacaMarketDataException: rate limited: 429',
|
|
),
|
|
];
|
|
}
|
|
|
|
List<AdminSyncRunRecord> fixtureFailedThenSuccessSameKind(DateTime base) {
|
|
return <AdminSyncRunRecord>[
|
|
adminSyncRun(
|
|
id: 21,
|
|
kind: 'backfill',
|
|
startedAt: base.subtract(const Duration(hours: 2)),
|
|
finishedAt: base.subtract(const Duration(hours: 1, minutes: 58)),
|
|
error: '429',
|
|
),
|
|
adminSyncRun(
|
|
id: 22,
|
|
kind: 'backfill',
|
|
startedAt: base,
|
|
finishedAt: base.add(const Duration(minutes: 1)),
|
|
rowsWritten: 1200,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<AdminSyncRunRecord> fixturePartialBackfillError(DateTime base) {
|
|
return <AdminSyncRunRecord>[
|
|
adminSyncRun(
|
|
id: 30,
|
|
kind: 'backfill',
|
|
startedAt: base,
|
|
finishedAt: base.add(const Duration(minutes: 5)),
|
|
rowsWritten: 12000,
|
|
error: 'batch MSFT,AAPL: server 500',
|
|
),
|
|
];
|
|
}
|
|
|
|
List<AdminSyncRunRecord> fixtureInProgressStale(DateTime base) {
|
|
return <AdminSyncRunRecord>[
|
|
adminSyncRun(
|
|
id: 40,
|
|
kind: 'cleanup',
|
|
startedAt: base.subtract(const Duration(hours: 2)),
|
|
finishedAt: null,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<AdminSyncRunRecord> fixtureMixedKindsMixedOutcomes(DateTime base) {
|
|
return <AdminSyncRunRecord>[
|
|
adminSyncRun(
|
|
id: 50,
|
|
kind: 'cleanup',
|
|
startedAt: base,
|
|
finishedAt: base.add(const Duration(minutes: 1)),
|
|
rowsRemoved: 4200,
|
|
),
|
|
adminSyncRun(
|
|
id: 51,
|
|
kind: 'backfill',
|
|
startedAt: base.subtract(const Duration(hours: 1)),
|
|
finishedAt: base.subtract(const Duration(minutes: 55)),
|
|
rowsWritten: 8000,
|
|
error: 'partial batch failure',
|
|
),
|
|
adminSyncRun(
|
|
id: 52,
|
|
kind: 'universe',
|
|
startedAt: base.subtract(const Duration(hours: 3)),
|
|
finishedAt: base.subtract(const Duration(hours: 2, minutes: 58)),
|
|
rowsWritten: 8200,
|
|
),
|
|
adminSyncRun(
|
|
id: 53,
|
|
kind: 'backfill',
|
|
startedAt: base.subtract(const Duration(hours: 5)),
|
|
finishedAt: base.subtract(const Duration(hours: 4, minutes: 58)),
|
|
error: '429',
|
|
),
|
|
];
|
|
}
|