fix(events): refresh saved payout calendars once per hourly pass (WealthLedger/backend#53) (#157)
This commit was merged in pull request #157.
This commit is contained in:
@@ -110,6 +110,7 @@ export class CatalogEnrichmentService {
|
||||
tickers?: Record<string, string>;
|
||||
to: string;
|
||||
},
|
||||
refreshBefore?: Date,
|
||||
) {
|
||||
const { revision } = await this.access.local(userId);
|
||||
const inputs = sourceInputs(instrumentType, uids, kinds, range);
|
||||
@@ -123,6 +124,7 @@ export class CatalogEnrichmentService {
|
||||
false,
|
||||
kinds,
|
||||
range,
|
||||
refreshBefore,
|
||||
);
|
||||
}
|
||||
const work = inputs.length
|
||||
@@ -175,6 +177,7 @@ export class CatalogEnrichmentService {
|
||||
tickers?: Record<string, string>;
|
||||
to: string;
|
||||
},
|
||||
refreshBefore?: Date,
|
||||
) {
|
||||
const inputs = sourceInputs(instrumentType, uids, kinds, range);
|
||||
const reservation = this.reservations.then(async () => {
|
||||
@@ -189,7 +192,9 @@ export class CatalogEnrichmentService {
|
||||
);
|
||||
const policy = sourcePolicy(input.kind);
|
||||
const needsRefresh = force || !row?.fetchedAt ||
|
||||
(policy === 'quote' && tbankSourceNeedsRefresh('quote', row.fetchedAt, new Date()));
|
||||
(policy === 'quote' && tbankSourceNeedsRefresh('quote', row.fetchedAt, new Date())) ||
|
||||
// A walk reads a saved calendar once: later accounts see the new fetchedAt.
|
||||
(policy === 'calendar' && refreshBefore !== undefined && row.fetchedAt < refreshBefore);
|
||||
if (!needsRefresh) {
|
||||
continue;
|
||||
}
|
||||
@@ -665,6 +670,7 @@ function sourcePolicy(kind: CatalogSource['kind']) {
|
||||
) {
|
||||
return 'quote';
|
||||
}
|
||||
if (['bond-events', 'dividends'].includes(kind)) return 'calendar';
|
||||
return 'stable';
|
||||
}
|
||||
function producerKey(input: CatalogSource) {
|
||||
|
||||
Reference in New Issue
Block a user