@ -93,52 +93,52 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit {
} ;
} ;
} ) ;
} ) ;
let date = parseISO ( this . dateOfFirstActivity ) ;
if ( this . dateOfFirstActivity ) {
let date = parseISO ( this . dateOfFirstActivity ) ;
const missingMarketData : Partial < MarketData > [ ] = [ ] ;
const missingMarketData : Partial < MarketData > [ ] = [ ] ;
if ( this . historicalDataItems ? . [ 0 ] ? . date ) {
while (
if ( this . historicalDataItems ? . [ 0 ] ? . date ) {
isBefore (
while (
date ,
isBefore (
parse ( this . historicalDataItems [ 0 ] . date , DATE_FORMAT , new Date ( ) )
date ,
)
parse ( this . historicalDataItems [ 0 ] . date , DATE_FORMAT , new Date ( ) )
) {
)
missingMarketData . push ( {
) {
date ,
missingMarketData . push ( {
marketPrice : undefined
date ,
} ) ;
marketPrice : undefined
} ) ;
date = addDays ( date , 1 ) ;
date = addDays ( date , 1 ) ;
}
}
}
}
const marketDataItems = [ . . . missingMarketData , . . . this . marketData ] ;
const marketDataItems = [ . . . missingMarketData , . . . this . marketData ] ;
if ( ! isToday ( last ( marketDataItems ) ? . date ) ) {
if ( ! isToday ( last ( marketDataItems ) ? . date ) ) {
marketDataItems . push ( { date : new Date ( ) } ) ;
marketDataItems . push ( { date : new Date ( ) } ) ;
}
}
this . marketDataByMonth = { } ;
this . marketDataByMonth = { } ;
for ( const marketDataItem of marketDataItems ) {
for ( const marketDataItem of marketDataItems ) {
const currentDay = parseInt ( format ( marketDataItem . date , 'd' ) , 10 ) ;
const currentDay = parseInt ( format ( marketDataItem . date , 'd' ) , 10 ) ;
const key = format ( marketDataItem . date , 'yyyy-MM' ) ;
const key = format ( marketDataItem . date , 'yyyy-MM' ) ;
if ( ! this . marketDataByMonth [ key ] ) {
if ( ! this . marketDataByMonth [ key ] ) {
this . marketDataByMonth [ key ] = { } ;
this . marketDataByMonth [ key ] = { } ;
}
}
this . marketDataByMonth [ key ] [
this . marketDataByMonth [ key ] [
currentDay < 10 ? ` 0 ${ currentDay } ` : currentDay
currentDay < 10 ? ` 0 ${ currentDay } ` : currentDay
] = {
] = {
date : marketDataItem.date ,
date : marketDataItem.date ,
day : currentDay ,
day : currentDay ,
marketPrice : marketDataItem.marketPrice
marketPrice : marketDataItem.marketPrice
} ;
} ;
}
}
if ( this . dateOfFirstActivity ) {
// Fill up missing months
// Fill up missing months
const dates = Object . keys ( this . marketDataByMonth ) . sort ( ) ;
const dates = Object . keys ( this . marketDataByMonth ) . sort ( ) ;
const startDate = min ( [
const startDate = min ( [