forked from thoughtworks/HeartBeat
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADM-693:[backend] feat: generate rework report (#1256)
* ADM-693:[backend] fix:revert to original logic in fetch done card data * ADM-693:[backend] fix: update rework time is null to zero * ADM-693:[backend] refactor: extract methods * ADM-693:[backend] refactor: extract generation of baseInfo and cycle time to the BoardSheetGenerator * ADM-693:[backend] feat: generate rework field in sheet * ADM-693:[backend] test: fix order of assert * ADM-693:[backend] fix: add rework total time in flat map * ADM-693: [frontend] fix: fix request param issue * ADM-693:[backend] fix: format rework fields * ADM-693:[backend] fix: use alias temporarily * ADM-693:[backend] test: add rework fields in sheet * ADM-693:[backend] refactor: only one condition * ADM-693:[backend] fix: pmd check * ADM-693:[backend] refactor: rename method * ADM-693:[backend] refactor: sort card steps enum * ADM-693:[docs] feat: return throughput in rework info * AMD-694 [frontend] test: add e2e for board metric rework both for create-a-new-project.spec and import-project-from-file.spec * AMD-693 [frontend] fix: add some columns in board metric.csv * ADM-693:[backend] feat: report rework metric in metric csc file * ADM-693:[frontend] fix: add rework data to e2e expect metric data csv * ADM-693:[backend] fix: fix sonar issue * ADM-693:[backend] fix: update constant name --------- Co-authored-by: Genhao Liu <[email protected]> Co-authored-by: GuangbinMa <[email protected]> Co-authored-by: yp.wu <[email protected]>
- Loading branch information
1 parent
c827401
commit b0fa28b
Showing
14 changed files
with
326 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
backend/src/main/java/heartbeat/service/report/BoardSheetGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package heartbeat.service.report; | ||
|
||
import heartbeat.controller.board.dto.response.JiraCardDTO; | ||
import heartbeat.controller.report.dto.response.BoardCSVConfig; | ||
import lombok.Builder; | ||
import org.apache.commons.collections4.CollectionUtils; | ||
import org.apache.commons.lang3.ArrayUtils; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
public class BoardSheetGenerator { | ||
|
||
private List<JiraCardDTO> jiraCardDTOList; | ||
|
||
private List<BoardCSVConfig> fields; | ||
|
||
private List<BoardCSVConfig> extraFields; | ||
|
||
private List<BoardCSVConfig> reworkFields; | ||
|
||
private CSVFileGenerator csvFileGenerator; | ||
|
||
private String[][] sheet; | ||
|
||
String[][] generate() { | ||
return sheet; | ||
} | ||
|
||
BoardSheetGenerator mergeBaseInfoAndCycleTimeSheet() { | ||
String[][] baseInfoAndCycleTimeSheet = csvFileGenerator.assembleBoardData(jiraCardDTOList, fields, extraFields); | ||
sheet = mergeSheetHorizontally(sheet, baseInfoAndCycleTimeSheet); | ||
return this; | ||
} | ||
|
||
BoardSheetGenerator mergeReworkTimesSheet() { | ||
if (CollectionUtils.isEmpty(reworkFields)) { | ||
return this; | ||
} | ||
int columnCount = reworkFields.size(); | ||
String[][] reworkTimesSheet = new String[jiraCardDTOList.size() + 1][columnCount]; | ||
|
||
for (int column = 0; column < columnCount; column++) { | ||
reworkTimesSheet[0][column] = reworkFields.get(column).getLabel(); | ||
} | ||
for (int row = 0; row < jiraCardDTOList.size(); row++) { | ||
JiraCardDTO cardDTO = jiraCardDTOList.get(row); | ||
for (int column = 0; column < columnCount; column++) { | ||
reworkTimesSheet[row + 1][column] = csvFileGenerator.getExtraDataPerRow(cardDTO.getReworkTimesFlat(), | ||
reworkFields.get(column)); | ||
} | ||
} | ||
sheet = mergeSheetHorizontally(sheet, reworkTimesSheet); | ||
return this; | ||
} | ||
|
||
private String[][] mergeSheetHorizontally(String[][] sheet, String[][] sheetToMerge) { | ||
int rows = jiraCardDTOList.size() + 1; | ||
String[][] combinedArray = new String[rows][]; | ||
if (ArrayUtils.isEmpty(sheet)) { | ||
return sheetToMerge; | ||
} | ||
for (int i = 0; i < rows; i++) { | ||
combinedArray[i] = ArrayUtils.addAll(sheet[i], sheetToMerge[i]); | ||
} | ||
return combinedArray; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.