2021-08-09 21:11:35 +02:00
|
|
|
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
2021-04-13 21:53:58 +02:00
|
|
|
import { Controller } from '@nestjs/common';
|
|
|
|
|
|
|
|
import { RedisCacheService } from './redis-cache/redis-cache.service';
|
|
|
|
|
|
|
|
@Controller()
|
|
|
|
export class AppController {
|
|
|
|
public constructor(
|
2021-08-09 21:11:35 +02:00
|
|
|
private readonly dataGatheringService: DataGatheringService,
|
2021-04-13 21:53:58 +02:00
|
|
|
private readonly redisCacheService: RedisCacheService
|
|
|
|
) {
|
|
|
|
this.initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
private async initialize() {
|
|
|
|
this.redisCacheService.reset();
|
|
|
|
|
2021-08-09 21:11:35 +02:00
|
|
|
const isDataGatheringInProgress =
|
|
|
|
await this.dataGatheringService.getIsInProgress();
|
2021-04-13 21:53:58 +02:00
|
|
|
|
2021-08-09 21:11:35 +02:00
|
|
|
if (isDataGatheringInProgress) {
|
|
|
|
// Prepare for automatical data gathering, if hung up in progress state
|
|
|
|
await this.dataGatheringService.reset();
|
2021-04-13 21:53:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|