Browse Source

Fix empty historical market data for asset profiles without activities

pull/7623/head
Thomas Kaul 2 weeks ago
parent
commit
59fa0a8ca9
  1. 10
      libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor.component.ts

10
libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor.component.ts

@ -41,7 +41,6 @@ import {
parse, parse,
parseISO parseISO
} from 'date-fns'; } from 'date-fns';
import { first, last } from 'lodash';
import ms from 'ms'; import ms from 'ms';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { parse as csvToJson } from 'papaparse'; import { parse as csvToJson } from 'papaparse';
@ -123,8 +122,7 @@ export class GfHistoricalMarketDataEditorComponent
} }
public ngOnChanges() { public ngOnChanges() {
const startDate = const startDate = this.dateOfFirstActivity ?? this.marketData()[0]?.date;
this.dateOfFirstActivity ?? first(this.marketData())?.date;
if (!startDate) { if (!startDate) {
return; return;
@ -152,7 +150,7 @@ export class GfHistoricalMarketDataEditorComponent
const marketDataItems = [...missingMarketData, ...this.marketData()]; const marketDataItems = [...missingMarketData, ...this.marketData()];
const lastDate = last(marketDataItems)?.date; const lastDate = marketDataItems.at(-1)?.date;
if (!lastDate || !isToday(lastDate)) { if (!lastDate || !isToday(lastDate)) {
marketDataItems.push({ date: new Date() }); marketDataItems.push({ date: new Date() });
} }
@ -178,8 +176,8 @@ export class GfHistoricalMarketDataEditorComponent
// Fill up missing months // Fill up missing months
const dates = Object.keys(this.marketDataByMonth).sort(); const dates = Object.keys(this.marketDataByMonth).sort();
const startDateString = first(dates); const startDateString = dates[0];
const endDateString = last(dates); const endDateString = dates.at(-1);
if (endDateString) { if (endDateString) {
const endDate = parseISO(endDateString); const endDate = parseISO(endDateString);

Loading…
Cancel
Save