refactor: retire legacy tbank-sync status and sync=observe (WealthLedger/backend#196)
This commit was merged in pull request #197.
This commit is contained in:
@@ -238,7 +238,6 @@ export class BrokerageOperationsService {
|
||||
userId: string,
|
||||
accountId: string,
|
||||
ranges: (openedAt: Date | undefined) => DateOnlyRange[],
|
||||
observe = false,
|
||||
) {
|
||||
const connection = await this.access.local(userId, accountId);
|
||||
const input = {
|
||||
@@ -252,21 +251,19 @@ export class BrokerageOperationsService {
|
||||
periods: ranges,
|
||||
};
|
||||
let saved = await this.repository.readPage(input);
|
||||
if (!observe) {
|
||||
const targets = (saved?.connection.accounts ?? []).flatMap((account) =>
|
||||
(saved?.periods ?? []).map((period) => ({
|
||||
accountId: account.accountId,
|
||||
...period,
|
||||
})),
|
||||
);
|
||||
if (targets.length) {
|
||||
await this.sync.readPlan(userId, targets, {
|
||||
movingEnd: saved?.periods?.some((period) => period.movingEnd),
|
||||
revision: connection.revision,
|
||||
});
|
||||
}
|
||||
saved = await this.repository.readPage(input);
|
||||
const targets = (saved?.connection.accounts ?? []).flatMap((account) =>
|
||||
(saved?.periods ?? []).map((period) => ({
|
||||
accountId: account.accountId,
|
||||
...period,
|
||||
})),
|
||||
);
|
||||
if (targets.length) {
|
||||
await this.sync.readPlan(userId, targets, {
|
||||
movingEnd: saved?.periods?.some((period) => period.movingEnd),
|
||||
revision: connection.revision,
|
||||
});
|
||||
}
|
||||
saved = await this.repository.readPage(input);
|
||||
const now = new Date();
|
||||
const hourly = await this.hourlySync.hourly(userId);
|
||||
const membership = investmentResourceMeta({
|
||||
|
||||
Reference in New Issue
Block a user