From a45868c53de5630e6f7cd684e9348e4545413824 Mon Sep 17 00:00:00 2001 From: s-vamshi Date: Thu, 16 Oct 2025 21:24:40 +0530 Subject: [PATCH] Feature/allow data gathering by date range --- CHANGELOG.md | 7 +++++ apps/api/src/app/admin/admin.controller.ts | 2 +- .../admin-market-data.component.ts | 2 +- .../asset-profile-dialog.component.ts | 31 +++++++++++++++++-- .../asset-profile-dialog.html | 18 +++++++++++ .../create-asset-profile-dialog.component.ts | 1 + apps/client/src/app/services/admin.service.ts | 17 ++++++++-- 7 files changed, 72 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48d622193..773560faf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,17 @@ 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 to allow data gathering by date range + ## 2.209.0 - 2025-10-18 ### Added +- Added support to allow data gathering by date range - Extended the glossary of the resources page by _Stealth Wealth_ - Extended the content of the pricing page - Added a _Storybook_ story for the holdings table component diff --git a/apps/api/src/app/admin/admin.controller.ts b/apps/api/src/app/admin/admin.controller.ts index 66f8483b4..d7c4c5d3d 100644 --- a/apps/api/src/app/admin/admin.controller.ts +++ b/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; } 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 e907f4b03..c24562239 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 @@ -336,7 +336,7 @@ export class GfAdminMarketDataComponent public onGatherSymbol({ dataSource, symbol }: AssetProfileIdentifier) { this.adminService - .gatherSymbol({ dataSource, symbol }) + .gatherSymbol({ range: undefined, dataSource, symbol }) .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(); } diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts index 3fd9e506f..25282a5d0 100644 --- a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts +++ b/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,26 @@ 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 +426,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(); } diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html index 301287cf5..b2c063684 100644 --- a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html +++ b/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 }) " > Gather Historical Market Data + + @for (dateRange of dateRangeOptions; track dateRange.value) { + + } +