Skip to content

Commit

Permalink
ADM-966 [backend]: add design and waiting for deployment to metrics c…
Browse files Browse the repository at this point in the history
…sv file
  • Loading branch information
zhou-yinyuan committed Aug 9, 2024
1 parent 8f4aa07 commit 6c5a276
Show file tree
Hide file tree
Showing 3 changed files with 316 additions and 273 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@

public enum CardStepsEnum {

TODO("To do", "To do"), ANALYSE("Analysis", "Analysis"), DESIGN("Design", "Design"),
DEVELOPMENT("In Dev", "In dev"), BLOCK("Block", "Block"), FLAG("FLAG", "Flag"),
REMOVEFLAG("removeFlag", "Remove flag"), REVIEW("Review", "Review"),
WAITING_FOR_TESTING("Waiting for testing", "Waiting for testing"), TESTING("Testing", "Testing"),
WAITING_FOR_DEPLOYMENT("Waiting for deployment", "Waiting for deployment"), DONE("Done", "Done"),
CLOSED("Closed", "Closed"), UNKNOWN("UNKNOWN", "Unknown");
TODO("To do", "To do", 0), ANALYSE("Analysis", "Analysis", 1), DESIGN("Design", "Design", 2),
DEVELOPMENT("In Dev", "In dev", 3), BLOCK("Block", "Block", 4), FLAG("FLAG", "Flag", 5),
REMOVEFLAG("removeFlag", "Remove flag", 6), REVIEW("Review", "Review", 7),
WAITING_FOR_TESTING("Waiting for testing", "Waiting for testing", 8), TESTING("Testing", "Testing", 9),
WAITING_FOR_DEPLOYMENT("Waiting for deployment", "Waiting for deployment", 10), DONE("Done", "Done", 11),
CLOSED("Closed", "Closed", 12), UNKNOWN("UNKNOWN", "Unknown", 13);

private final String value;

private final String alias;

CardStepsEnum(String value, String alias) {
private final int order;

CardStepsEnum(String value, String alias, int order) {
this.value = value;
this.alias = alias;
this.order = order;
}

public String getValue() {
Expand All @@ -29,6 +32,10 @@ public String getAlias() {
return alias;
}

public int getOrder() {
return order;
}

public static CardStepsEnum fromValue(String type) {
for (CardStepsEnum cardStepsEnum : values()) {
if (cardStepsEnum.value.equals(type)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import heartbeat.client.dto.pipeline.buildkite.BuildKiteBuildInfo;
import heartbeat.controller.board.dto.request.CardStepsEnum;
import heartbeat.controller.report.dto.response.PipelineChangeFailureRateOfPipeline;
import heartbeat.controller.report.dto.response.PipelineMeanTimeToRecovery;
import heartbeat.repository.FilePrefixType;
Expand Down Expand Up @@ -35,13 +36,14 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.core.io.InputStreamResource;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Map;
import java.util.stream.Stream;

Expand Down Expand Up @@ -390,16 +392,13 @@ private List<String[]> getRowsFromCycleTime(CycleTime cycleTime) {
String.valueOf(cycleTime.getAverageCycleTimePerCard()) });
List<CycleTimeForSelectedStepItem> swimlaneList = cycleTime.getSwimlaneList();

swimlaneList.stream()
.filter(it -> Objects.equals(it.getOptionalItemName(), "Analysis"))
.findFirst()
.ifPresent(analysisItem -> {
swimlaneList
.removeIf(it -> Objects.equals(it.getOptionalItemName(), analysisItem.getOptionalItemName()));
swimlaneList.add(1, analysisItem);
});
List<CycleTimeForSelectedStepItem> sortedSwimlaneList = swimlaneList.stream()
.map(it -> Pair.of(it, CardStepsEnum.fromValue(it.getOptionalItemName()).getOrder()))
.sorted(Comparator.comparing(Pair::getRight))
.map(Pair::getLeft)
.toList();

swimlaneList.forEach(cycleTimeForSelectedStepItem -> {
sortedSwimlaneList.forEach(cycleTimeForSelectedStepItem -> {
String stepName = formatStepName(cycleTimeForSelectedStepItem);
double proportion = cycleTimeForSelectedStepItem.getTotalTime() / cycleTime.getTotalTimeForCards();
rows.add(new String[] { cycleTimeTitle, "Total " + stepName + " time / Total cycle time(%)",
Expand Down Expand Up @@ -433,6 +432,8 @@ private String formatStepName(CycleTimeForSelectedStepItem cycleTimeForSelectedS
case "Testing" -> "testing";
case "Analysis" -> "analysis";
case "Waiting for testing" -> "waiting for testing";
case "Design" -> "design";
case "Waiting for deployment" -> "waiting for deployment";
default -> "";
};
}
Expand Down
Loading

0 comments on commit 6c5a276

Please sign in to comment.