Browse Source

fix: resolve exchange rate errors from silent failure, reference bug, and missing dataSource filter

Three fixes for exchange rate reliability with MANUAL data source:

1. app.controller.ts: Log error in catch block instead of swallowing.
   The empty catch {} hides exchange rate initialization failures.

2. exchange-rate-data.service.ts: Use spread copy instead of reference
   assignment for resultExtended, preventing mutation of the source
   object during reverse-rate computation.

3. manual.service.ts: Add dataSource filter to MarketData query so
   DISTINCT ON (symbol) returns the correct row for symbols with
   entries from multiple data providers.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
pull/7267/head
Shane Greaves 1 week ago
parent
commit
73622699cf
  1. 8
      apps/api/src/app/app.controller.ts
  2. 3
      apps/api/src/services/data-provider/manual/manual.service.ts
  3. 2
      apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts

8
apps/api/src/app/app.controller.ts

@ -1,9 +1,11 @@
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service';
import { Controller } from '@nestjs/common';
import { Controller, Logger } from '@nestjs/common';
@Controller()
export class AppController {
private readonly logger = new Logger(AppController.name);
public constructor(
private readonly exchangeRateDataService: ExchangeRateDataService
) {
@ -13,6 +15,8 @@ export class AppController {
private async initialize() {
try {
await this.exchangeRateDataService.initialize();
} catch {}
} catch (error) {
this.logger.error(error);
}
}
}

3
apps/api/src/services/data-provider/manual/manual.service.ts

@ -161,7 +161,8 @@ export class ManualService implements DataProviderInterface {
where: {
symbol: {
in: symbols
}
},
dataSource: this.getName()
}
});

2
apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts

@ -203,7 +203,7 @@ export class ExchangeRateDataService {
}
}
const resultExtended = result;
const resultExtended = { ...result };
for (const symbol of Object.keys(result)) {
const [currency1, currency2] = symbol.match(/.{1,3}/g);

Loading…
Cancel
Save