Browse Source

Feature/allow data gathering by date range (#5762)

* Allow data gathering by date range

* Update changelog
pull/5787/head^2
s-vamshi 15 hours ago
committed by GitHub
parent
commit
a65523fd04
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      CHANGELOG.md
  2. 2
      apps/api/src/app/admin/admin.controller.ts
  3. 37
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  4. 18
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
  5. 18
      apps/client/src/app/services/admin.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 data gathering by date range in the asset profile details dialog of the admin control panel
## 2.209.0 - 2025-10-18
### Added

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

@ -169,7 +169,7 @@ export class AdminController {
let date: Date;
if (dateRange) {
const { startDate } = getIntervalFromDateRange(dateRange, new Date());
const { startDate } = getIntervalFromDateRange(dateRange);
date = startDate;
}

37
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

@ -18,6 +18,7 @@ import {
ScraperConfiguration,
User
} from '@ghostfolio/common/interfaces';
import { DateRange } from '@ghostfolio/common/types';
import { GfCurrencySelectorComponent } from '@ghostfolio/ui/currency-selector';
import { GfEntityLogoComponent } from '@ghostfolio/ui/entity-logo';
import { GfHistoricalMarketDataEditorComponent } from '@ghostfolio/ui/historical-market-data-editor';
@ -190,6 +191,32 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit {
};
public currencies: string[] = [];
public dateRangeOptions = [
{
label: $localize`Current week` + ' (' + $localize`WTD` + ')',
value: 'wtd'
},
{
label: $localize`Current month` + ' (' + $localize`MTD` + ')',
value: 'mtd'
},
{
label: $localize`Current year` + ' (' + $localize`YTD` + ')',
value: 'ytd'
},
{
label: '1 ' + $localize`year` + ' (' + $localize`1Y` + ')',
value: '1y'
},
{
label: '5 ' + $localize`years` + ' (' + $localize`5Y` + ')',
value: '5y'
},
{
label: $localize`Max`,
value: 'max'
}
];
public historicalDataItems: LineChartItem[];
public isBenchmark = false;
public isDataGatheringEnabled: boolean;
@ -405,9 +432,15 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit {
.subscribe();
}
public onGatherSymbol({ dataSource, symbol }: AssetProfileIdentifier) {
public onGatherSymbol({
dataSource,
range,
symbol
}: {
range?: DateRange;
} & AssetProfileIdentifier) {
this.adminService
.gatherSymbol({ dataSource, symbol })
.gatherSymbol({ dataSource, range, symbol })
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe();
}

18
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html

@ -26,12 +26,30 @@
[disabled]="
assetProfileForm.dirty || !assetProfileForm.controls.isActive.value
"
[matMenuTriggerFor]="gatherHistoricalMarketDataMenu"
(click)="
onGatherSymbol({ dataSource: data.dataSource, symbol: data.symbol })
"
>
<ng-container i18n>Gather Historical Market Data</ng-container>
</button>
<mat-menu #gatherHistoricalMarketDataMenu="matMenu">
@for (dateRange of dateRangeOptions; track dateRange.value) {
<button
mat-menu-item
type="button"
(click)="
onGatherSymbol({
dataSource: data.dataSource,
range: dateRange.value,
symbol: data.symbol
})
"
>
{{ dateRange.label }}
</button>
}
</mat-menu>
<button
mat-menu-item
type="button"

18
apps/client/src/app/services/admin.service.ts

@ -17,6 +17,7 @@ import {
EnhancedSymbolProfile,
Filter
} from '@ghostfolio/common/interfaces';
import { DateRange } from '@ghostfolio/common/types';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
@ -178,9 +179,22 @@ export class AdminService {
);
}
public gatherSymbol({ dataSource, symbol }: AssetProfileIdentifier) {
public gatherSymbol({
dataSource,
range,
symbol
}: {
range?: DateRange;
} & AssetProfileIdentifier) {
let params = new HttpParams();
if (range) {
params = params.append('range', range);
}
const url = `/api/v1/admin/gather/${dataSource}/${symbol}`;
return this.http.post<MarketData | void>(url, {});
return this.http.post<MarketData | void>(url, undefined, { params });
}
public fetchSymbolForDate({

Loading…
Cancel
Save