Browse Source

Task/improve type safety in queue and i18n services (#8413)

Improve type safety
pull/8427/head
Kenrick Tandrian 2 weeks ago
committed by GitHub
parent
commit
2823510bf4
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      apps/api/src/services/i18n/i18n.service.ts
  2. 27
      apps/api/src/services/queues/data-gathering/data-gathering.service.ts
  3. 4
      apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.service.mock.ts

2
apps/api/src/services/i18n/i18n.service.ts

@ -29,7 +29,7 @@ export class I18nService implements OnModuleInit {
return routerLink.map((link) => { return routerLink.map((link) => {
const match = link.match(I18nService.TRANSLATION_TAGGED_MESSAGE_REGEX); const match = link.match(I18nService.TRANSLATION_TAGGED_MESSAGE_REGEX);
const segment = match const segment = match?.groups
? this.getTranslation({ ? this.getTranslation({
languageCode, languageCode,
id: match.groups.id id: match.groups.id

27
apps/api/src/services/queues/data-gathering/data-gathering.service.ts

@ -104,7 +104,11 @@ export class DataGatheringService {
); );
for (const assetProfile of Object.values(assetProfiles)) { for (const assetProfile of Object.values(assetProfiles)) {
const { symbol } = assetProfile; const { dataSource, symbol } = assetProfile;
if (!dataSource || !symbol) {
continue;
}
const symbolProfile = symbolProfiles.find( const symbolProfile = symbolProfiles.find(
({ symbol: symbolProfileSymbol }) => { ({ symbol: symbolProfileSymbol }) => {
@ -145,7 +149,6 @@ export class DataGatheringService {
countries, countries,
currency, currency,
cusip, cusip,
dataSource,
figi, figi,
figiComposite, figiComposite,
figiShareClass, figiShareClass,
@ -161,19 +164,19 @@ export class DataGatheringService {
create: { create: {
assetClass, assetClass,
assetSubClass, assetSubClass,
countries,
currency,
cusip, cusip,
dataSource, dataSource,
figi, figi,
figiComposite, figiComposite,
figiShareClass, figiShareClass,
holdings,
isin, isin,
name, name,
sectors,
symbol, symbol,
url url,
countries: countries ?? undefined,
currency: currency as string,
holdings: holdings ?? undefined,
sectors: sectors ?? undefined
}, },
update: { update: {
assetClass, assetClass,
@ -187,9 +190,11 @@ export class DataGatheringService {
name, name,
url, url,
// Keep the stored data if no list is available // Keep the stored data if no list is available
countries: isEmpty(countries) ? undefined : countries, countries: isEmpty(countries)
holdings: isEmpty(holdings) ? undefined : holdings, ? undefined
sectors: isEmpty(sectors) ? undefined : sectors : (countries ?? undefined),
holdings: isEmpty(holdings) ? undefined : (holdings ?? undefined),
sectors: isEmpty(sectors) ? undefined : (sectors ?? undefined)
}, },
where: { where: {
dataSource_symbol: { dataSource_symbol: {
@ -408,7 +413,7 @@ export class DataGatheringService {
jobId: `${getAssetProfileIdentifier({ jobId: `${getAssetProfileIdentifier({
dataSource, dataSource,
symbol symbol
})}-${format(date, DATE_FORMAT, { in: utc })}` })}-${format(date as Date, DATE_FORMAT, { in: utc })}`
} }
}; };
}) })

4
apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.service.mock.ts

@ -31,7 +31,9 @@ export const PortfolioSnapshotServiceMock = {
} }
}; };
PortfolioSnapshotServiceMock.jobsStore.set(opts?.jobId, mockJob); if (opts?.jobId) {
PortfolioSnapshotServiceMock.jobsStore.set(opts.jobId, mockJob);
}
return Promise.resolve(mockJob as Job); return Promise.resolve(mockJob as Job);
}, },

Loading…
Cancel
Save