From 10dfda903100f7b32ac6839a5ac263c7a4a93823 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 20 Dec 2023 12:06:36 +0100 Subject: [PATCH] Fix statistics --- frontend/src/api/model/taskgroupPathInfo.ts | 1 + .../taskgroup-activity.component.ts | 42 ++++++++++++++++--- openapi.yaml | 4 ++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/frontend/src/api/model/taskgroupPathInfo.ts b/frontend/src/api/model/taskgroupPathInfo.ts index b13e526..a7faa8e 100644 --- a/frontend/src/api/model/taskgroupPathInfo.ts +++ b/frontend/src/api/model/taskgroupPathInfo.ts @@ -18,5 +18,6 @@ export interface TaskgroupPathInfo { */ taskgroupPath: string; directChildren: Array; + rootTasktroup: TaskgroupEntityInfo; } diff --git a/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.ts b/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.ts index caf6965..0631364 100644 --- a/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.ts +++ b/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.ts @@ -88,10 +88,13 @@ export class TaskgroupActivityComponent implements OnInit{ createDateRangeBetween(minValue: moment.Moment, maxValue: moment.Moment) { const dates: Date[] = []; - const numberDays = maxValue.diff(minValue, 'days'); - for(let i=0; i<=numberDays; i++) { - dates.push(minValue.add(i, 'd').toDate()); + let currentDate = moment(minValue); + + while(currentDate <= maxValue) { + dates.push(currentDate.toDate()); + currentDate = currentDate.add(1, 'days'); } + return dates; } @@ -100,19 +103,24 @@ export class TaskgroupActivityComponent implements OnInit{ //console.log("onUserChangeStart" + new Date(changeContext.value)); } + onUserChangeStop(changeContext: ChangeContext) { //console.log("onUserChangeStop" + new Date(changeContext.highValue!)) } onUserChange(changeContext: ChangeContext) { - const dateRange = this.createDateRangeBetween(moment(changeContext.value), moment(changeContext.highValue!)) + console.log("min " + moment(changeContext.value).format("YYYY-MM-DD")); + console.log("max " + moment(changeContext.highValue!).format("YYYY-MM-DD")) + this.selectedDateRange = this.createDateRangeBetween(moment(changeContext.value), moment(changeContext.highValue!)) this.chartOptions = this.generateChartOptions() } generateChartOptions(): Partial { + const series = this.generateSeries(); + return { - series: this.generateSeries(), + series: series, chart: { height: 350, type: this.selectedChartype as ChartType, @@ -129,7 +137,30 @@ export class TaskgroupActivityComponent implements OnInit{ generateSeries() : ApexAxisChartSeries { const series: ApexAxisChartSeries = [] + + if(this.selectedTaskgroupPath != undefined) { + this.historyService.statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet( + this.selectedTaskgroupPath!.rootTasktroup.taskgroupID, + moment(this.selectedDateRange[0]).format("YYYY-MM-DD"), + moment(this.selectedDateRange[this.selectedDateRange.length-1]).format("YYYY-MM-DD"), + false + ).subscribe({ + next: resp => { + series.push( + { + name: this.selectedTaskgroupPath!.rootTasktroup.taskgroupName, + data: resp.map(dailyActivityInfo => dailyActivityInfo.activeMinutes) + } + ); + } + }) + } + + + + this.selectedTaskgroupPath?.directChildren.forEach(taskgroup => { + this.historyService.statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet( taskgroup.taskgroupID, moment(this.selectedDateRange[0]).format("YYYY-MM-DD"), @@ -146,6 +177,7 @@ export class TaskgroupActivityComponent implements OnInit{ }) }) + console.log(series); return series; } diff --git a/openapi.yaml b/openapi.yaml index 0e7f7e5..b77674a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2612,6 +2612,7 @@ components: required: - taskgroupPath - directChildren + - rootTasktroup additionalProperties: false properties: taskgroupPath: @@ -2621,6 +2622,9 @@ components: type: array items: $ref: '#/components/schemas/TaskgroupEntityInfo' + rootTasktroup: + type: object + $ref: '#/components/schemas/TaskgroupEntityInfo' TaskgroupActivityInfo: required: - date