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) => {
const match = link.match(I18nService.TRANSLATION_TAGGED_MESSAGE_REGEX);
const segment = match
const segment = match?.groups
? this.getTranslation({
languageCode,
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)) {
const { symbol } = assetProfile;
const { dataSource, symbol } = assetProfile;
if (!dataSource || !symbol) {
continue;
}
const symbolProfile = symbolProfiles.find(
({ symbol: symbolProfileSymbol }) => {
@ -145,7 +149,6 @@ export class DataGatheringService {
countries,
currency,
cusip,
dataSource,
figi,
figiComposite,
figiShareClass,
@ -161,19 +164,19 @@ export class DataGatheringService {
create: {
assetClass,
assetSubClass,
countries,
currency,
cusip,
dataSource,
figi,
figiComposite,
figiShareClass,
holdings,
isin,
name,
sectors,
symbol,
url
url,
countries: countries ?? undefined,
currency: currency as string,
holdings: holdings ?? undefined,
sectors: sectors ?? undefined
},
update: {
assetClass,
@ -187,9 +190,11 @@ export class DataGatheringService {
name,
url,
// Keep the stored data if no list is available
countries: isEmpty(countries) ? undefined : countries,
holdings: isEmpty(holdings) ? undefined : holdings,
sectors: isEmpty(sectors) ? undefined : sectors
countries: isEmpty(countries)
? undefined
: (countries ?? undefined),
holdings: isEmpty(holdings) ? undefined : (holdings ?? undefined),
sectors: isEmpty(sectors) ? undefined : (sectors ?? undefined)
},
where: {
dataSource_symbol: {
@ -408,7 +413,7 @@ export class DataGatheringService {
jobId: `${getAssetProfileIdentifier({
dataSource,
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);
},

Loading…
Cancel
Save