Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADM-1003: [frontend][backend][docs]: re-calculate the lead time for changes for source control data in the report page #1601

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b9a6eba
ADM-1003 [backend]: feat: get lead time data for source control
zhou-yinyuan Sep 6, 2024
152a6a1
ADM-1003 [frontend]: fix: fix the next button in the metrics page
zhou-yinyuan Sep 6, 2024
3806501
ADM-1003 [frontend]: fix: fix the request in the report page
zhou-yinyuan Sep 6, 2024
a852969
ADM-1003 [backend]: test: fix backend test
zhou-yinyuan Sep 6, 2024
c4974a8
ADM-1003 [backend]: feat: change the structure for repo data
zhou-yinyuan Sep 6, 2024
ec5d3e8
ADM-999 [frontend][backend]: fix the error path (#1598)
zhou-yinyuan Sep 6, 2024
a6cfc2c
ADM-1003 [backend]: feat: re-calculate lead time for changes with sou…
zhou-yinyuan Sep 9, 2024
05f250a
ADM-1003 [backend]: style: format
zhou-yinyuan Sep 9, 2024
9e4b449
ADM-1003 [backend]: feat: save source control data to file for share api
zhou-yinyuan Sep 9, 2024
fca4b53
ADM-1003 [frontend]: feat: change the frontend content and style
zhou-yinyuan Sep 9, 2024
a99ac15
ADM-1003 [backend]: feat: update metrics csv file and refactor
zhou-yinyuan Sep 9, 2024
513f77a
ADM-1003 [backend]: fix: fix crew bug when the crew is empty
zhou-yinyuan Sep 9, 2024
67612fe
ADM-1003 [backend]: feat: update the pipeline csv file
zhou-yinyuan Sep 10, 2024
f836a0c
ADM-1003 [backend][frontend]: fix: fix sonar issues
zhou-yinyuan Sep 10, 2024
f350802
ADM-1003 [frontend]: fix: fix comments
zhou-yinyuan Sep 10, 2024
eb3e5a7
ADM-1003 [frontend]: fix: fix sonar issues
zhou-yinyuan Sep 10, 2024
0d89cf5
ADM-1003 [frontend]: test: fix e2e test
zhou-yinyuan Sep 10, 2024
8c5165b
ADM-1003 [frontend]: test: add e2e test content for lead time for cha…
zhou-yinyuan Sep 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions backend/src/main/java/heartbeat/client/GitHubFeignClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import heartbeat.client.dto.codebase.github.BranchesInfoDTO;
import heartbeat.client.dto.codebase.github.CommitInfo;
import heartbeat.client.dto.codebase.github.OrganizationsInfoDTO;
import heartbeat.client.dto.codebase.github.PullRequestInfo;

import heartbeat.client.dto.codebase.github.PullRequestInfoDTO;
import heartbeat.client.dto.codebase.github.PullRequestInfo;
import heartbeat.client.dto.codebase.github.ReposInfoDTO;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cloud.openfeign.FeignClient;
Expand Down Expand Up @@ -66,7 +65,7 @@ ResponseEntity<List<BranchesInfoDTO>> getAllBranches(@RequestHeader("Authorizati

@GetMapping(path = "/repos/{org}/{repo}/pulls")
@ResponseStatus(HttpStatus.OK)
ResponseEntity<List<PullRequestInfoDTO>> getAllPullRequests(@RequestHeader("Authorization") String token,
ResponseEntity<List<PullRequestInfo>> getAllPullRequests(@RequestHeader("Authorization") String token,
@PathVariable("org") String org, @PathVariable("repo") String repo, @RequestParam("per_page") int perPage,
@RequestParam("page") int page, @RequestParam("base") String base, @RequestParam("state") String state);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package heartbeat.client.dto.codebase.github;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -13,6 +14,9 @@
@AllArgsConstructor
public class CommitInfo implements Serializable {

@JsonProperty("sha")
private String commitId;

private Commit commit;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public class LeadTime {

private String commitId;

private String committer;

private Integer pullNumber;

@Nullable
private Long prCreatedTime;

Expand All @@ -23,17 +27,17 @@ public class LeadTime {
@Nullable
private Long firstCommitTimeInPr;

private long jobFinishTime;
private Long jobFinishTime;

private long jobStartTime;
private Long jobStartTime;

@Nullable
private Long noPRCommitTime;

@Nullable
private Long firstCommitTime;

private long pipelineCreateTime;
private Long pipelineCreateTime;

@Nullable
private Boolean isRevert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PagePullRequestInfoDTO implements Serializable {
public class PagePullRequestInfo implements Serializable {

private int totalPage;

private List<PullRequestInfoDTO> pageInfo;
private List<PullRequestInfo> pageInfo;

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package heartbeat.client.dto.codebase.github;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand All @@ -14,6 +16,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public class PullRequestInfo implements Serializable {

private Integer number;
Expand All @@ -29,4 +32,17 @@ public class PullRequestInfo implements Serializable {
@JsonProperty("merge_commit_sha")
private String mergeCommitSha;

private PullRequestUser user;

@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public static class PullRequestUser implements Serializable {

private String login;

}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package heartbeat.client.dto.codebase.github;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SourceControlLeadTime {

private String organization;

private String repo;

private String branch;

private List<LeadTime> leadTimes;

}
5 changes: 2 additions & 3 deletions backend/src/main/java/heartbeat/config/CacheConfig.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package heartbeat.config;

import heartbeat.client.dto.board.jira.CardHistoryResponseDTO;
import heartbeat.client.dto.board.jira.CalendarificHolidayResponseDTO;
import heartbeat.client.dto.board.jira.FieldResponseDTO;
import heartbeat.client.dto.board.jira.HolidaysResponseDTO;
import heartbeat.client.dto.board.jira.JiraBoardConfigDTO;
Expand All @@ -11,7 +10,7 @@
import heartbeat.client.dto.codebase.github.CommitInfo;
import heartbeat.client.dto.codebase.github.PageBranchesInfoDTO;
import heartbeat.client.dto.codebase.github.PageOrganizationsInfoDTO;
import heartbeat.client.dto.codebase.github.PagePullRequestInfoDTO;
import heartbeat.client.dto.codebase.github.PagePullRequestInfo;
import heartbeat.client.dto.codebase.github.PageReposInfoDTO;
import heartbeat.client.dto.pipeline.buildkite.BuildKiteTokenInfo;
import heartbeat.client.dto.pipeline.buildkite.PageBuildKitePipelineInfoDTO;
Expand Down Expand Up @@ -64,7 +63,7 @@ public CacheManager ehCacheManager() {
cacheManager.createCache("pageOrganization", getCacheConfiguration(PageOrganizationsInfoDTO.class));
cacheManager.createCache("pageRepo", getCacheConfiguration(PageReposInfoDTO.class));
cacheManager.createCache("pageBranch", getCacheConfiguration(PageBranchesInfoDTO.class));
cacheManager.createCache("pagePullRequest", getCacheConfiguration(PagePullRequestInfoDTO.class));
cacheManager.createCache("pagePullRequest", getCacheConfiguration(PagePullRequestInfo.class));
return cacheManager;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package heartbeat.controller.report.dto.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CodeBase {

private List<String> branches;

private String repo;

private String organization;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ public class CodebaseSetting {

private List<DeploymentEnvironment> leadTime;

private List<String> crews;

private List<CodeBase> codebases;

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package heartbeat.controller.report.dto.response;

import heartbeat.util.DecimalUtil;
import io.micrometer.core.instrument.util.TimeUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

import static java.util.concurrent.TimeUnit.HOURS;

@Data
@Builder
@NoArgsConstructor
Expand All @@ -20,4 +27,15 @@ public class AvgLeadTimeForChanges {

private Double totalDelayTime;

public List<String[]> getMetricsCsvRowData(String leadTimeForChangesTitle) {
List<String[]> rows = new ArrayList<>();
rows.add(new String[] { leadTimeForChangesTitle, name + " / PR Lead Time",
DecimalUtil.formatDecimalTwo(TimeUtils.minutesToUnit(prLeadTime, HOURS)) });
rows.add(new String[] { leadTimeForChangesTitle, name + " / Pipeline Lead Time",
DecimalUtil.formatDecimalTwo(TimeUtils.minutesToUnit(pipelineLeadTime, HOURS)) });
rows.add(new String[] { leadTimeForChangesTitle, name + " / Total Lead Time",
DecimalUtil.formatDecimalTwo(TimeUtils.minutesToUnit(totalDelayTime, HOURS)) });
return rows;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class LeadTimeForChanges {

private List<LeadTimeForChangesOfPipelines> leadTimeForChangesOfPipelines;

private List<LeadTimeForChangesOfSourceControl> leadTimeForChangesOfSourceControls;

private AvgLeadTimeForChanges avgLeadTimeForChanges;

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package heartbeat.controller.report.dto.response;

import heartbeat.util.DecimalUtil;
import io.micrometer.core.instrument.util.TimeUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

import static java.util.concurrent.TimeUnit.HOURS;

@Data
@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -21,4 +28,20 @@ public class LeadTimeForChangesOfPipelines {

private Double totalDelayTime;

private String extractPipelineStep(String step) {
return step.replaceAll(":\\w+: ", "");
}

public List<String[]> getMetricsCsvRowData(String leadTimeForChangesTitle) {
List<String[]> rows = new ArrayList<>();
String pipelineStep = extractPipelineStep(this.step);
rows.add(new String[] { leadTimeForChangesTitle, this.name + " / " + pipelineStep + " / PR Lead Time",
DecimalUtil.formatDecimalTwo(TimeUtils.minutesToUnit(prLeadTime, HOURS)) });
rows.add(new String[] { leadTimeForChangesTitle, this.name + " / " + pipelineStep + " / Pipeline Lead Time",
DecimalUtil.formatDecimalTwo(TimeUtils.minutesToUnit(pipelineLeadTime, HOURS)) });
rows.add(new String[] { leadTimeForChangesTitle, this.name + " / " + pipelineStep + " / Total Lead Time",
DecimalUtil.formatDecimalTwo(TimeUtils.minutesToUnit(totalDelayTime, HOURS)) });
return rows;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package heartbeat.controller.report.dto.response;

import heartbeat.util.DecimalUtil;
import io.micrometer.core.instrument.util.TimeUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

import static java.util.concurrent.TimeUnit.HOURS;

@AllArgsConstructor
@Builder
@NoArgsConstructor
@Data
public class LeadTimeForChangesOfSourceControl {

private String organization;

private String repo;

private Double prLeadTime;

private Double pipelineLeadTime;

private Double totalDelayTime;

public List<String[]> getMetricsCsvRowData(String leadTimeForChangesTitle) {
List<String[]> rows = new ArrayList<>();
rows.add(new String[] { leadTimeForChangesTitle, organization + " / " + repo + " / PR Lead Time",
DecimalUtil.formatDecimalTwo(TimeUtils.minutesToUnit(prLeadTime, HOURS)) });
rows.add(new String[] { leadTimeForChangesTitle, organization + " / " + repo + " / Pipeline Lead Time",
DecimalUtil.formatDecimalTwo(TimeUtils.minutesToUnit(pipelineLeadTime, HOURS)) });
rows.add(new String[] { leadTimeForChangesTitle, organization + " / " + repo + " / Total Lead Time",
DecimalUtil.formatDecimalTwo(TimeUtils.minutesToUnit(totalDelayTime, HOURS)) });
return rows;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
@AllArgsConstructor
public class LeadTimeInfo {

private Integer pullNumber;

@Nullable
private String prCreatedTime;

Expand Down Expand Up @@ -43,17 +45,21 @@ public class LeadTimeInfo {

private long nonWorkdays;

private String committer;

public LeadTimeInfo(LeadTime leadTime) {
if (leadTime == null) {
return;
}
this.pullNumber = leadTime.getPullNumber();
this.firstCommitTimeInPr = convertToISOFormat(leadTime.getFirstCommitTimeInPr());
this.prCreatedTime = convertToISOFormat(leadTime.getPrCreatedTime());
this.prMergedTime = convertToISOFormat(leadTime.getPrMergedTime());
this.jobFinishTime = convertToISOFormat(leadTime.getJobFinishTime());
this.jobStartTime = convertToISOFormat(leadTime.getJobStartTime());
this.firstCommitTime = convertToISOFormat(leadTime.getFirstCommitTime());
this.noPRCommitTime = convertToISOFormat(leadTime.getNoPRCommitTime());
this.committer = leadTime.getCommitter();

this.pipelineLeadTime = TimeUtil.msToHMS(leadTime.getPipelineLeadTime());
this.isRevert = leadTime.getIsRevert();
Expand Down
Loading
Loading