diff --git a/apps/api/src/app/admin/admin.controller.ts b/apps/api/src/app/admin/admin.controller.ts index 9eb045fba..a6f6e8b6f 100644 --- a/apps/api/src/app/admin/admin.controller.ts +++ b/apps/api/src/app/admin/admin.controller.ts @@ -86,8 +86,8 @@ export class AdminController { @HasPermission(permissions.accessAdminControl) @Post('gather') @UseGuards(AuthGuard('jwt'), HasPermissionGuard) - public async gather7Days(): Promise { - this.dataGatheringService.gather7Days(); + public async gatherRecentMarketData(): Promise { + this.dataGatheringService.gatherRecentMarketData(); } @HasPermission(permissions.accessAdminControl) diff --git a/apps/api/src/services/cron/cron.module.ts b/apps/api/src/services/cron/cron.module.ts index 3d999e397..bc14990c1 100644 --- a/apps/api/src/services/cron/cron.module.ts +++ b/apps/api/src/services/cron/cron.module.ts @@ -2,8 +2,6 @@ import { UserModule } from '@ghostfolio/api/app/user/user.module'; import { UserService } from '@ghostfolio/api/app/user/user.service'; import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; -import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.module'; -import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; import { PropertyModule } from '@ghostfolio/api/services/property/property.module'; import { PropertyService } from '@ghostfolio/api/services/property/property.service'; import { DataGatheringQueueModule } from '@ghostfolio/api/services/queues/data-gathering/data-gathering.module'; @@ -21,7 +19,6 @@ import { CronService } from './cron.service'; imports: [ ConfigurationModule, DataGatheringQueueModule, - ExchangeRateDataModule, PropertyModule, StatisticsGatheringQueueModule, TwitterBotModule, @@ -32,7 +29,6 @@ import { CronService } from './cron.service'; inject: [ ConfigurationService, DataGatheringService, - ExchangeRateDataService, PropertyService, StatisticsGatheringService, TwitterBotService, @@ -42,7 +38,6 @@ import { CronService } from './cron.service'; useFactory: ( configurationService: ConfigurationService, dataGatheringService: DataGatheringService, - exchangeRateDataService: ExchangeRateDataService, propertyService: PropertyService, statisticsGatheringService: StatisticsGatheringService, twitterBotService: TwitterBotService, @@ -57,7 +52,6 @@ import { CronService } from './cron.service'; return new CronService( configurationService, dataGatheringService, - exchangeRateDataService, propertyService, statisticsGatheringService, twitterBotService, diff --git a/apps/api/src/services/cron/cron.service.ts b/apps/api/src/services/cron/cron.service.ts index 7299cbbf4..a0d71e794 100644 --- a/apps/api/src/services/cron/cron.service.ts +++ b/apps/api/src/services/cron/cron.service.ts @@ -1,6 +1,5 @@ import { UserService } from '@ghostfolio/api/app/user/user.service'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; -import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; import { PropertyService } from '@ghostfolio/api/services/property/property.service'; import { DataGatheringService } from '@ghostfolio/api/services/queues/data-gathering/data-gathering.service'; import { StatisticsGatheringService } from '@ghostfolio/api/services/queues/statistics-gathering/statistics-gathering.service'; @@ -24,7 +23,6 @@ export class CronService { public constructor( private readonly configurationService: ConfigurationService, private readonly dataGatheringService: DataGatheringService, - private readonly exchangeRateDataService: ExchangeRateDataService, private readonly propertyService: PropertyService, private readonly statisticsGatheringService: StatisticsGatheringService, private readonly twitterBotService: TwitterBotService, @@ -41,16 +39,11 @@ export class CronService { @Cron(CronService.EVERY_HOUR_AT_RANDOM_MINUTE) public async runEveryHourAtRandomMinute() { if (await this.isDataGatheringEnabled()) { - await this.dataGatheringService.gather7Days(); - await this.dataGatheringService.gatherHourlySymbols(); + await this.dataGatheringService.gatherRecentMarketData(); + await this.dataGatheringService.gatherHourlyMarketData(); } } - @Cron(CronExpression.EVERY_12_HOURS) - public async runEveryTwelveHours() { - await this.exchangeRateDataService.loadCurrencies(); - } - @Cron(CronExpression.EVERY_DAY_AT_5PM) public async runEveryDayAtFivePm() { if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { diff --git a/apps/api/src/services/queues/data-gathering/data-gathering.service.ts b/apps/api/src/services/queues/data-gathering/data-gathering.service.ts index ff65ebc83..810768ef5 100644 --- a/apps/api/src/services/queues/data-gathering/data-gathering.service.ts +++ b/apps/api/src/services/queues/data-gathering/data-gathering.service.ts @@ -69,7 +69,7 @@ export class DataGatheringService { return this.dataGatheringQueue.addBulk(jobs); } - public async gather7Days() { + public async gatherRecentMarketData() { await this.gatherSymbols({ dataGatheringItems: await this.getCurrencies7D(), priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH @@ -282,7 +282,13 @@ export class DataGatheringService { } } - public async gatherHourlySymbols() { + public async gatherHourlyMarketData() { + try { + await this.exchangeRateDataService.loadCurrencies(); + } catch (error) { + this.logger.error('Could not gather exchange rates', error); + } + const assetProfileIdentifiers = await this.getHourlyAssetProfileIdentifiers(); diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.component.ts b/apps/client/src/app/components/admin-market-data/admin-market-data.component.ts index 511d6df98..ae0f8fda2 100644 --- a/apps/client/src/app/components/admin-market-data/admin-market-data.component.ts +++ b/apps/client/src/app/components/admin-market-data/admin-market-data.component.ts @@ -305,17 +305,6 @@ export class GfAdminMarketDataComponent implements AfterViewInit, OnInit { ); } - protected onGather7Days() { - this.adminService - .gather7Days() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(() => { - setTimeout(() => { - window.location.reload(); - }, 300); - }); - } - protected onGatherMax() { this.adminService .gatherMax() @@ -334,6 +323,17 @@ export class GfAdminMarketDataComponent implements AfterViewInit, OnInit { .subscribe(); } + protected onGatherRecentMarketData() { + this.adminService + .gatherRecentMarketData() + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => { + setTimeout(() => { + window.location.reload(); + }, 300); + }); + } + protected onOpenAssetProfileDialog({ dataSource, symbol diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.html b/apps/client/src/app/components/admin-market-data/admin-market-data.html index e86e3e631..270722a4b 100644 --- a/apps/client/src/app/components/admin-market-data/admin-market-data.html +++ b/apps/client/src/app/components/admin-market-data/admin-market-data.html @@ -220,7 +220,7 @@ class="no-max-width" xPosition="before" > -