Skip to content

Commit ed9ec40

Browse files
author
richard.bunel@opendigitaleducation.com
committed
[Fix] #19841 : stats to zero
1 parent b7684f3 commit ed9ec40

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/main/resources/public/ts/controller.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ export const statsController = ng.controller('StatsController', ['$scope', '$roo
182182
chartGranularity: "month",
183183
chartDatasets: function(){ return $scope.profileDataSets() },
184184
getValue: function(container){
185-
var default_granularity = this.type + "_MONTH"
186-
var lastAggreg = container.getLastAggregation()
187-
return (typeof lastAggreg === "object" && !isNaN(lastAggreg[default_granularity])) ? lastAggreg[default_granularity] : 0
185+
return container.uniqueVisitorOfTheMonth
188186
},
189187
getChartData: function(container){
190188
var aggregationFunction
@@ -221,10 +219,8 @@ export const statsController = ng.controller('StatsController', ['$scope', '$roo
221219
getValue: function(container){
222220
var refDate = new Date()
223221
$scope.toMidnight(refDate).setDate(1)
224-
var lastAggreg = container.getLastAggregation()
225-
226222
var connections = container.getAggregatedSum("LOGIN", refDate)
227-
var uniqueVisitors = (typeof lastAggreg === "object" && !isNaN(lastAggreg["UNIQUE_VISITORS_MONTH"])) ? lastAggreg["UNIQUE_VISITORS_MONTH"] : 0
223+
var uniqueVisitors = container.uniqueVisitorOfTheMonth
228224
return uniqueVisitors > 0 ? Math.round((connections / uniqueVisitors) * 100)/100 : 0
229225
},
230226
getChartData: function(container){

src/main/resources/public/ts/model.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ export const statistics = {
1919
this.name = data.name
2020
this.groups = data.groups ? data.groups : {}
2121
this.data = []
22+
this.uniqueVisitorOfTheMonth = 0
2223
this.get()
23-
this.getProfiles()
24+
/*this.getProfiles()
2425
this.getModules()
2526
this.getModulesByProfile()
27+
this.getChartData("UNIQUE_VISITORS_MONTH",statistics.scope.monthlySumFunction,statistics.scope.date)*/
2628
},
2729
scope: {} as any
2830
}
@@ -73,6 +75,7 @@ statistics.IndicatorContainer.prototype = {
7375
stats.data[prop] = data[prop]
7476
}
7577
if(statistics.scope) statistics.scope.$apply()
78+
stats.getProfiles()
7679
})
7780
},
7881
//AJAX get - retrieves values by profile
@@ -87,6 +90,7 @@ statistics.IndicatorContainer.prototype = {
8790
return http().get(this.API_PATH + 'list' + getquery).done(function(data){
8891
stats.data.profil = data
8992
if(statistics.scope) statistics.scope.$apply()
93+
stats.getModules()
9094
})
9195
},
9296
//AJAX get - retrieves values by module
@@ -101,6 +105,7 @@ statistics.IndicatorContainer.prototype = {
101105
return http().get(this.API_PATH + 'list' + getquery).done(function(data){
102106
stats.data.module = data
103107
if(statistics.scope) statistics.scope.$apply()
108+
stats.getModulesByProfile()
104109
})
105110
},
106111
//AJAX GET - retrieves values by profile by module
@@ -115,6 +120,7 @@ statistics.IndicatorContainer.prototype = {
115120
return http().get(this.API_PATH + 'list' + getquery).done(function(data){
116121
stats.data.moduleByProfile = data
117122
if(statistics.scope) statistics.scope.$apply()
123+
stats.getChartData("UNIQUE_VISITORS_MONTH",statistics.scope.lastDayOfMonthAggregationFunction,statistics.scope.date)
118124
})
119125
},
120126
//Returns the last value (date wise)
@@ -276,6 +282,8 @@ statistics.IndicatorContainer.prototype = {
276282
refDate = refDate.add(1, 'd')
277283
}
278284

285+
this.uniqueVisitorOfTheMonth = chartData[chartData.length-1][0];
286+
279287
return chartData
280288
}
281289
}

0 commit comments

Comments
 (0)