diff --git a/core/src/main/java/io/aiven/klaw/helpers/KwConstants.java b/core/src/main/java/io/aiven/klaw/helpers/KwConstants.java index e3d44c8a7d..270f2e70ed 100644 --- a/core/src/main/java/io/aiven/klaw/helpers/KwConstants.java +++ b/core/src/main/java/io/aiven/klaw/helpers/KwConstants.java @@ -150,4 +150,7 @@ public class KwConstants { public static final DateTimeFormatter DATE_TIME_DDMMMYYYY_HHMMSS_FORMATTER = DateTimeFormatter.ofPattern("dd-MMM-yyyy HH:mm:ss").withZone(ZoneId.systemDefault()); + + public static final DateTimeFormatter DATE_DDMMMYYYY_FORMATTER = + DateTimeFormatter.ofPattern("dd-MMM-yyyy").withZone(ZoneId.systemDefault()); } diff --git a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/SelectDataJdbc.java b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/SelectDataJdbc.java index b751d9874d..a66e8c1ed5 100644 --- a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/SelectDataJdbc.java +++ b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/SelectDataJdbc.java @@ -1,7 +1,7 @@ package io.aiven.klaw.helpers.db.rdbms; -import static io.aiven.klaw.helpers.KwConstants.DATE_TIME_DDMMMYYYY_HHMMSS_FORMATTER; -import static io.aiven.klaw.helpers.KwConstants.REQUESTOR_SUBSCRIPTIONS; +import static io.aiven.klaw.helpers.KwConstants.*; +import static org.reflections.Reflections.log; import com.google.common.collect.Lists; import io.aiven.klaw.dao.*; @@ -15,24 +15,15 @@ import io.aiven.klaw.model.response.DashboardStats; import io.aiven.klaw.repository.*; import io.aiven.klaw.service.CommonUtilsService; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.TreeSet; +import java.util.*; import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.stereotype.Component; @@ -1101,12 +1092,11 @@ public List> selectActivi Integer teamId, int numberOfDays, int tenantId) { try { List> res = new ArrayList<>(); - List fromDb = + List> fromDb = gatherActivityList( activityLogRepo.findActivityLogForTeamIdForLastNDays(teamId, tenantId, numberOfDays)); - for (int elem : fromDb) { - - res.add(CommonUtilsService.ChartsOverviewItem.of("activitycount", elem)); + for (Pair elem : fromDb) { + res.add(CommonUtilsService.ChartsOverviewItem.of(elem.getKey(), elem.getValue())); } return res; } catch (Exception e) { @@ -1119,11 +1109,11 @@ public List> selectActivi int numberOfDays, String[] envIdList, int tenantId) { try { List> res = new ArrayList<>(); - List fromDb = + List> fromDb = gatherActivityList( activityLogRepo.findActivityLogForLastNDays(envIdList, tenantId, numberOfDays)); - for (int elem : fromDb) { - res.add(CommonUtilsService.ChartsOverviewItem.of("activitycount", elem)); + for (Pair elem : fromDb) { + res.add(CommonUtilsService.ChartsOverviewItem.of(elem.getKey(), elem.getValue())); } return res; } catch (Exception e) { @@ -1146,10 +1136,14 @@ public static ActivityCountItem of(String dateOfActivity, int activityCount) { } } - private List gatherActivityList(List activityCount) { - List res = new ArrayList<>(activityCount.size()); + private List> gatherActivityList(List activityCount) { + List> res = new ArrayList<>(activityCount.size()); for (Object[] activity : activityCount) { - res.add((((Long) activity[1]).intValue())); + + res.add( + new ImmutablePair<>( + DATE_DDMMMYYYY_FORMATTER.format(((java.sql.Date) activity[0]).toLocalDate()), + ((Long) activity[1]).intValue())); } return res; } @@ -1287,6 +1281,7 @@ public List> selectAclsC Map envIds = topics.stream() .collect(Collectors.toMap(e -> (String) e[0], e -> ((Long) e[1]).intValue())); + Map name2envsFromDb = StreamSupport.stream(selectEnvsDetails(envIds.keySet(), tenantId).spliterator(), false) .collect(Collectors.toMap(Env::getName, Function.identity()));