Feature/add missing dates to edit historical market data in asset profile details dialog (#3206)
* Add missing dates to edit historical market data in asset profile details dialog * Update changelog
This commit is contained in:
parent
0581b8b9ec
commit
a668a66e84
@ -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
|
||||
|
||||
### Fixed
|
||||
|
||||
- Added missing dates to edit historical market data in the asset profile details dialog of the admin control panel
|
||||
|
||||
## 2.68.0 - 2024-03-29
|
||||
|
||||
### Added
|
||||
|
@ -9,11 +9,7 @@
|
||||
[showYAxis]="true"
|
||||
[symbol]="symbol"
|
||||
/>
|
||||
<div
|
||||
*ngFor="let itemByMonth of marketDataByMonth | keyvalue"
|
||||
class="d-flex"
|
||||
[hidden]="!marketData.length > 0"
|
||||
>
|
||||
<div *ngFor="let itemByMonth of marketDataByMonth | keyvalue" class="d-flex">
|
||||
<div class="date px-1 text-nowrap">{{ itemByMonth.key }}</div>
|
||||
<div class="align-items-center d-flex flex-grow-1 px-1">
|
||||
<div
|
||||
|
@ -19,15 +19,17 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
import { DataSource, MarketData } from '@prisma/client';
|
||||
import {
|
||||
addDays,
|
||||
addMonths,
|
||||
format,
|
||||
isBefore,
|
||||
isSameDay,
|
||||
isToday,
|
||||
isValid,
|
||||
min,
|
||||
parse,
|
||||
parseISO
|
||||
} from 'date-fns';
|
||||
import { last } from 'lodash';
|
||||
import { first, last } from 'lodash';
|
||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
||||
import { Subject, takeUntil } from 'rxjs';
|
||||
|
||||
@ -135,6 +137,27 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit {
|
||||
marketPrice: marketDataItem.marketPrice
|
||||
};
|
||||
}
|
||||
|
||||
if (this.dateOfFirstActivity) {
|
||||
// Fill up missing months
|
||||
const dates = Object.keys(this.marketDataByMonth).sort();
|
||||
const startDate = min([
|
||||
parseISO(this.dateOfFirstActivity),
|
||||
parseISO(first(dates))
|
||||
]);
|
||||
const endDate = parseISO(last(dates));
|
||||
|
||||
let currentDate = startDate;
|
||||
|
||||
while (isBefore(currentDate, endDate)) {
|
||||
const key = format(currentDate, 'yyyy-MM');
|
||||
if (!this.marketDataByMonth[key]) {
|
||||
this.marketDataByMonth[key] = {};
|
||||
}
|
||||
|
||||
currentDate = addMonths(currentDate, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public isDateOfInterest(aDateString: string) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user