feat: reconcile hourly investment resource states
This commit is contained in:
@@ -17,6 +17,10 @@ import {
|
||||
ledgerRange,
|
||||
planInvestmentScreen,
|
||||
} from '../../investment-sync-plan';
|
||||
import {
|
||||
hourlyAttempt,
|
||||
TbankSyncRepository,
|
||||
} from '../../tbank-sync/tbank-sync.repository';
|
||||
import { OperationErrorCode } from '../domain/operation-error-code';
|
||||
import {
|
||||
confirmedOperationRanges,
|
||||
@@ -59,6 +63,7 @@ export class BrokerageOperationsService {
|
||||
private readonly sync: BrokerageOperationsSyncService,
|
||||
private readonly membership: TbankMembershipService,
|
||||
private readonly config: ConfigService,
|
||||
private readonly hourlySync: TbankSyncRepository,
|
||||
) {}
|
||||
|
||||
async read(
|
||||
@@ -145,6 +150,7 @@ export class BrokerageOperationsService {
|
||||
});
|
||||
}
|
||||
const saved = await this.repository.readPage(readInput);
|
||||
const hourly = await this.hourlySync.hourly(userId);
|
||||
const accounts = saved?.connection.accounts ?? [];
|
||||
const targets = accounts.flatMap((account) =>
|
||||
from < to
|
||||
@@ -243,6 +249,7 @@ export class BrokerageOperationsService {
|
||||
? STALE_FRESHNESS_MS
|
||||
: Number.POSITIVE_INFINITY,
|
||||
work: work ?? saved?.membershipWork ?? null,
|
||||
lastAttempt: hourlyAttempt(hourly, 'operations', accountId === 'all' ? undefined : accountId),
|
||||
dependencies: [membershipMeta, ...metadataDependencies],
|
||||
coverage: {
|
||||
requested: targets.map(serialize),
|
||||
@@ -294,7 +301,7 @@ export class BrokerageOperationsService {
|
||||
const hasNext = Boolean(saved && saved.rows.length > limit);
|
||||
return {
|
||||
data:
|
||||
meta.availability === 'missing'
|
||||
meta.completeness === 'incomplete'
|
||||
? null
|
||||
: {
|
||||
accountId,
|
||||
|
||||
Reference in New Issue
Block a user