@@ -10,10 +10,10 @@ type SharedStorageUsageItem = {
10
10
count : number ;
11
11
avgSize : number ;
12
12
total : number ;
13
- cost : number ;
13
+ totalCost : number ;
14
14
avgCost : number ;
15
- costPerDay : number ;
16
15
pricePerUnit : number ;
16
+ costPerDay : number ;
17
17
} ;
18
18
19
19
@Component ( {
@@ -43,13 +43,12 @@ export class TableSharedStorageComponent implements OnChanges, AfterViewInit {
43
43
const workflowEntry = acc . find ( a => a . repo === line . repositorySlug ) ;
44
44
const date = line . date ;
45
45
const month : string = date . toLocaleString ( 'default' , { month : 'short' } ) ;
46
- const cost = line . pricePerUnit * line . quantity ;
46
+ const cost = line . quantity * line . pricePerUnit ;
47
47
if ( workflowEntry ) {
48
- const daysInMonth = new Date ( date . getFullYear ( ) , date . getMonth ( ) + 1 , 0 ) . getDate ( ) ;
49
48
if ( ( workflowEntry as any ) [ month ] as any ) {
50
- ( workflowEntry as any ) [ month ] += this . currency === 'cost' ? line . value * daysInMonth : line . value ;
49
+ ( workflowEntry as any ) [ month ] += line . value ;
51
50
} else {
52
- ( workflowEntry as any ) [ month ] = this . currency === 'cost' ? line . value * daysInMonth : line . value ;
51
+ ( workflowEntry as any ) [ month ] = line . value ;
53
52
}
54
53
if ( ! this . columns . find ( c => c . columnDef === month ) ) {
55
54
this . columns . push ( {
@@ -63,19 +62,20 @@ export class TableSharedStorageComponent implements OnChanges, AfterViewInit {
63
62
} ) ;
64
63
}
65
64
workflowEntry . total += line . quantity ;
66
- workflowEntry . cost += cost ;
65
+ workflowEntry . totalCost += cost ;
67
66
workflowEntry . count ++ ;
67
+ workflowEntry . costPerDay = cost ;
68
68
} else {
69
69
acc . push ( {
70
70
repo : line . repositorySlug ,
71
71
total : line . quantity ,
72
72
count : 1 ,
73
- cost,
73
+ totalCost : cost ,
74
74
avgSize : 0 ,
75
75
avgCost : 0 ,
76
76
[ month ] : line . value ,
77
77
pricePerUnit : line . pricePerUnit ,
78
- costPerDay : 0 ,
78
+ costPerDay : cost
79
79
} ) ;
80
80
}
81
81
return acc ;
@@ -87,8 +87,7 @@ export class TableSharedStorageComponent implements OnChanges, AfterViewInit {
87
87
( sharedStorageItem as any ) [ column . columnDef ] = 0 ;
88
88
}
89
89
sharedStorageItem . avgSize = sharedStorageItem . total / sharedStorageItem . count ;
90
- sharedStorageItem . avgCost = sharedStorageItem . cost / sharedStorageItem . count ;
91
- sharedStorageItem . costPerDay = sharedStorageItem . total * sharedStorageItem . pricePerUnit ;
90
+ sharedStorageItem . avgCost = sharedStorageItem . totalCost / sharedStorageItem . count ;
92
91
} ) ;
93
92
} ) ;
94
93
@@ -128,8 +127,8 @@ export class TableSharedStorageComponent implements OnChanges, AfterViewInit {
128
127
{
129
128
columnDef : 'total' ,
130
129
header : 'Total Cost' ,
131
- cell : ( sharedStorageItem : any ) => currencyPipe . transform ( sharedStorageItem . cost ) ,
132
- footer : ( ) => currencyPipe . transform ( this . dataSource . data . reduce ( ( acc , line ) => acc + line . cost , 0 ) )
130
+ cell : ( sharedStorageItem : any ) => currencyPipe . transform ( sharedStorageItem . totalCost ) ,
131
+ footer : ( ) => currencyPipe . transform ( this . dataSource . data . reduce ( ( acc , line ) => acc + line . totalCost , 0 ) )
133
132
} ,
134
133
{
135
134
columnDef : 'costPerDay' ,
0 commit comments