Include root Taskgroup in statistics and sort activityData by dates
All checks were successful
Java CI with Maven / test (push) Successful in 39s
Java CI with Maven / build-and-push-frontend (push) Successful in 7s
Java CI with Maven / build-and-push-backend (push) Successful in 7s

This commit is contained in:
Sebastian 2023-12-20 11:39:05 +01:00
parent 29a74b934a
commit 303de733a1
3 changed files with 22 additions and 2 deletions

View File

@ -23,6 +23,7 @@ import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -59,7 +60,14 @@ public class StatisticController {
return ResponseEntity.status(404).body(new SimpleStatusResponse("failed")); return ResponseEntity.status(404).body(new SimpleStatusResponse("failed"));
} }
return ResponseEntity.ok(taskgroupPermissionResult.getResult().calcActivityInfo(includeSubTaskgroups, List<TaskgroupActivityInfo> activityInfos = taskgroupPermissionResult.getResult().calcActivityInfo(includeSubTaskgroups,
LocalDate.parse(startingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")), LocalDate.parse(endingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")))); LocalDate.parse(startingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")), LocalDate.parse(endingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
activityInfos.sort(new Comparator<TaskgroupActivityInfo>() {
@Override
public int compare(TaskgroupActivityInfo o1, TaskgroupActivityInfo o2) {
return o1.getDate().compareTo(o2.getDate());
}
});
return ResponseEntity.ok(activityInfos);
} }
} }

View File

@ -17,4 +17,12 @@ public class TaskgroupActivityInfo {
this.date = localDate; this.date = localDate;
this.activeMinutes = activeMinutes; this.activeMinutes = activeMinutes;
} }
public LocalDate getDate() {
return date;
}
public int getActiveMinutes() {
return activeMinutes;
}
} }

View File

@ -11,6 +11,9 @@ public class TaskgroupPathInfo {
@JsonProperty @JsonProperty
private String taskgroupPath; private String taskgroupPath;
@JsonProperty
private TaskgroupEntityInfo rootTasktroup;
@JsonProperty @JsonProperty
private List<TaskgroupEntityInfo> directChildren; private List<TaskgroupEntityInfo> directChildren;
public TaskgroupPathInfo(Taskgroup taskgroup) { public TaskgroupPathInfo(Taskgroup taskgroup) {
@ -21,6 +24,7 @@ public class TaskgroupPathInfo {
stringBuilder.append("/"); stringBuilder.append("/");
} }
this.taskgroupPath = stringBuilder.substring(0, stringBuilder.length()-1); this.taskgroupPath = stringBuilder.substring(0, stringBuilder.length()-1);
this.rootTasktroup = new TaskgroupEntityInfo(taskgroup);
directChildren = taskgroup.getChildren().stream().map(TaskgroupEntityInfo::new).toList(); directChildren = taskgroup.getChildren().stream().map(TaskgroupEntityInfo::new).toList();
} }
} }