Browse Source

Feature/add date range query parameter to data gathering endpoint (#5684)

* Add date range

* Update changelog
pull/5610/head^2
Thomas Kaul 2 weeks ago
committed by GitHub
parent
commit
180e0f3c81
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      CHANGELOG.md
  2. 18
      apps/api/src/app/admin/admin.controller.ts
  3. 14
      apps/api/src/services/queues/data-gathering/data-gathering.service.ts

6
CHANGELOG.md

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Added
- Added support for a date range query parameter in the data gathering endpoint
## 2.206.0 - 2025-10-04
### Changed

18
apps/api/src/app/admin/admin.controller.ts

@ -6,6 +6,7 @@ import { ManualService } from '@ghostfolio/api/services/data-provider/manual/man
import { DemoService } from '@ghostfolio/api/services/demo/demo.service';
import { PropertyDto } from '@ghostfolio/api/services/property/property.dto';
import { DataGatheringService } from '@ghostfolio/api/services/queues/data-gathering/data-gathering.service';
import { getIntervalFromDateRange } from '@ghostfolio/common/calculation-helper';
import {
DATA_GATHERING_QUEUE_PRIORITY_HIGH,
DATA_GATHERING_QUEUE_PRIORITY_MEDIUM,
@ -22,6 +23,7 @@ import {
} from '@ghostfolio/common/interfaces';
import { permissions } from '@ghostfolio/common/permissions';
import type {
DateRange,
MarketDataPreset,
RequestWithUser
} from '@ghostfolio/common/types';
@ -161,9 +163,21 @@ export class AdminController {
@HasPermission(permissions.accessAdminControl)
public async gatherSymbol(
@Param('dataSource') dataSource: DataSource,
@Param('symbol') symbol: string
@Param('symbol') symbol: string,
@Query('range') dateRange: DateRange
): Promise<void> {
this.dataGatheringService.gatherSymbol({ dataSource, symbol });
let date: Date;
if (dateRange) {
const { startDate } = getIntervalFromDateRange(dateRange, new Date());
date = startDate;
}
this.dataGatheringService.gatherSymbol({
dataSource,
date,
symbol
});
return;
}

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

@ -94,17 +94,21 @@ export class DataGatheringService {
});
}
public async gatherSymbol({ dataSource, symbol }: AssetProfileIdentifier) {
public async gatherSymbol({ dataSource, date, symbol }: IDataGatheringItem) {
await this.marketDataService.deleteMany({ dataSource, symbol });
const dataGatheringItems = (await this.getSymbolsMax()).filter(
(dataGatheringItem) => {
const dataGatheringItems = (await this.getSymbolsMax())
.filter((dataGatheringItem) => {
return (
dataGatheringItem.dataSource === dataSource &&
dataGatheringItem.symbol === symbol
);
}
);
})
.map((item) => ({
...item,
date: date ?? item.date
}));
await this.gatherSymbols({
dataGatheringItems,
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH

Loading…
Cancel
Save