Browse Source

Fix date conversion in import of historical market data (#3117)

* Fix date conversion in import of historical market data

* Update changelog
pull/3143/head^2
helgehatt 11 months ago
committed by GitHub
parent
commit
a0ddd1f9b9
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      CHANGELOG.md
  2. 3
      apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.ts
  3. 2
      apps/client/src/app/components/admin-market-data-detail/market-data-detail-dialog/interfaces/interfaces.ts
  4. 4
      apps/client/src/app/components/admin-market-data-detail/market-data-detail-dialog/market-data-detail-dialog.component.ts
  5. 2
      apps/client/src/app/components/admin-market-data-detail/market-data-detail-dialog/market-data-detail-dialog.html
  6. 7
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  7. 9
      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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Fixed
- Fixed the date conversion of the import of historical market data in the admin control panel
## 2.63.2 - 2024-03-12 ## 2.63.2 - 2024-03-12
### Added ### Added

3
apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.ts

@ -155,15 +155,14 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit {
day: string; day: string;
yearMonth: string; yearMonth: string;
}) { }) {
const date = parseISO(`${yearMonth}-${day}`);
const marketPrice = this.marketDataByMonth[yearMonth]?.[day]?.marketPrice; const marketPrice = this.marketDataByMonth[yearMonth]?.[day]?.marketPrice;
const dialogRef = this.dialog.open(MarketDataDetailDialog, { const dialogRef = this.dialog.open(MarketDataDetailDialog, {
data: <MarketDataDetailDialogParams>{ data: <MarketDataDetailDialogParams>{
date,
marketPrice, marketPrice,
currency: this.currency, currency: this.currency,
dataSource: this.dataSource, dataSource: this.dataSource,
dateString: `${yearMonth}-${day}`,
symbol: this.symbol, symbol: this.symbol,
user: this.user user: this.user
}, },

2
apps/client/src/app/components/admin-market-data-detail/market-data-detail-dialog/interfaces/interfaces.ts

@ -5,7 +5,7 @@ import { DataSource } from '@prisma/client';
export interface MarketDataDetailDialogParams { export interface MarketDataDetailDialogParams {
currency: string; currency: string;
dataSource: DataSource; dataSource: DataSource;
date: Date; dateString: string;
marketPrice: number; marketPrice: number;
symbol: string; symbol: string;
user: User; user: User;

4
apps/client/src/app/components/admin-market-data-detail/market-data-detail-dialog/market-data-detail-dialog.component.ts

@ -45,7 +45,7 @@ export class MarketDataDetailDialog implements OnDestroy {
this.adminService this.adminService
.fetchSymbolForDate({ .fetchSymbolForDate({
dataSource: this.data.dataSource, dataSource: this.data.dataSource,
date: this.data.date, dateString: this.data.dateString,
symbol: this.data.symbol symbol: this.data.symbol
}) })
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
@ -63,7 +63,7 @@ export class MarketDataDetailDialog implements OnDestroy {
marketData: { marketData: {
marketData: [ marketData: [
{ {
date: this.data.date.toISOString(), date: this.data.dateString,
marketPrice: this.data.marketPrice marketPrice: this.data.marketPrice
} }
] ]

2
apps/client/src/app/components/admin-market-data-detail/market-data-detail-dialog/market-data-detail-dialog.html

@ -9,7 +9,7 @@
matInput matInput
name="date" name="date"
[matDatepicker]="date" [matDatepicker]="date"
[(ngModel)]="data.date" [(ngModel)]="data.dateString"
/> />
<mat-datepicker-toggle class="mr-2" matSuffix [for]="date"> <mat-datepicker-toggle class="mr-2" matSuffix [for]="date">
<ion-icon <ion-icon

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

@ -1,4 +1,5 @@
import { UpdateAssetProfileDto } from '@ghostfolio/api/app/admin/update-asset-profile.dto'; import { UpdateAssetProfileDto } from '@ghostfolio/api/app/admin/update-asset-profile.dto';
import { UpdateMarketDataDto } from '@ghostfolio/api/app/admin/update-market-data.dto';
import { AdminService } from '@ghostfolio/client/services/admin.service'; import { AdminService } from '@ghostfolio/client/services/admin.service';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { DATE_FORMAT, parseDate } from '@ghostfolio/common/helper'; import { DATE_FORMAT, parseDate } from '@ghostfolio/common/helper';
@ -195,15 +196,13 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
header: true, header: true,
skipEmptyLines: true skipEmptyLines: true
} }
).data; ).data as UpdateMarketDataDto[];
this.adminService this.adminService
.postMarketData({ .postMarketData({
dataSource: this.data.dataSource, dataSource: this.data.dataSource,
marketData: { marketData: {
marketData: marketData.map(({ date, marketPrice }) => { marketData
return { marketPrice, date: parseDate(date).toISOString() };
})
}, },
symbol: this.data.symbol symbol: this.data.symbol
}) })

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

@ -188,17 +188,14 @@ export class AdminService {
public fetchSymbolForDate({ public fetchSymbolForDate({
dataSource, dataSource,
date, dateString,
symbol symbol
}: { }: {
dataSource: DataSource; dataSource: DataSource;
date: Date; dateString: string;
symbol: string; symbol: string;
}) { }) {
const url = `/api/v1/symbol/${dataSource}/${symbol}/${format( const url = `/api/v1/symbol/${dataSource}/${symbol}/${dateString}`;
date,
DATE_FORMAT
)}`;
return this.http.get<IDataProviderHistoricalResponse>(url); return this.http.get<IDataProviderHistoricalResponse>(url);
} }

Loading…
Cancel
Save