Projekt

Obecné

Profil

« Předchozí | Další » 

Revize e5272be8

Přidáno uživatelem Ondřej Váně před asi 4 roky(ů)

Repair anti-pattern too long sprint

Zobrazit rozdíly:

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/DatabaseConnection.java
94 94
        return allResults;
95 95
    }
96 96

  
97
    public List<Map<String,Object>> resultSetToArrayList(ResultSet rs) throws SQLException {
97
    private List<Map<String,Object>> resultSetToArrayList(ResultSet rs) throws SQLException {
98 98
        ResultSetMetaData md = rs.getMetaData();
99 99
        int columns = md.getColumnCount();
100 100
        List<Map<String, Object>> list = new ArrayList<>();
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/TooLongSprintDetectorImpl.java
12 12
import java.sql.SQLException;
13 13
import java.util.ArrayList;
14 14
import java.util.List;
15
import java.util.Map;
15 16

  
16 17
public class TooLongSprintDetectorImpl implements AntiPatternDetector {
17 18

  
......
34 35
     * SETTINGS
35 36
     */
36 37
    private static final int MAX_NUMBER_OF_TOO_LONG_ITERATIONS = 1;
38
    private static final int MAX_ITERATION_LENGTH = 21;
37 39

  
38 40

  
39 41
    @Override
......
69 71
        int numberOfLongIterations = 0;
70 72
        int totalCountOfIteration = 0;
71 73

  
72
        // get results from sql queries
73
        try {
74
            ResultSet rs = databaseConnection.executeQueries(project, this.sqlQueries);
75
            if (rs != null) {
76
                while (rs.next()) {
77
                    totalCountOfIteration++;
78
                    boolean isTooLongSprint = rs.getBoolean("isTooLongSprint");
79
                    if (isTooLongSprint) {
80
                        numberOfLongIterations++;
81
                    }
82
                }
83
            }
74
        List<List<Map<String, Object>>> resultSets = databaseConnection.executeQueriesWithMultipleResults(project, this.sqlQueries);
75
        List<Map<String, Object>> rs = resultSets.get(0);
84 76

  
85
        } catch (SQLException e) {
86
            LOGGER.error("Cannot read results from db");
87
            List<ResultDetail> resultDetails = new ArrayList<>();
88
            resultDetails.add(new ResultDetail("Problem in reading database", e.toString()));
89
            return new QueryResultItem(this.antiPattern, true, resultDetails);
77
        for (Map<String, Object> iterationLengths : rs) {
78
            totalCountOfIteration++;
79
            if (!iterationLengths.containsKey("iterationLength") || iterationLengths.get("iterationLength") == null)
80
                continue;
81
            int iterationLength = (int) iterationLengths.get("iterationLength");
82
            if (iterationLength > MAX_ITERATION_LENGTH) {
83
                numberOfLongIterations++;
84
            }
90 85
        }
91

  
92 86
        List<ResultDetail> resultDetails = new ArrayList<>();
93
        resultDetails.add(new ResultDetail("Count of iterations", String.valueOf(totalCountOfIteration)));
87
        resultDetails.add(new ResultDetail("Count of iterations without first and last", String.valueOf(totalCountOfIteration)));
94 88
        resultDetails.add(new ResultDetail("Number of too long iterations", String.valueOf(numberOfLongIterations)));
95 89
        if (numberOfLongIterations >= MAX_NUMBER_OF_TOO_LONG_ITERATIONS) {
96 90
            resultDetails.add(new ResultDetail("Conclusion", "One or more iteration is too long"));
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/VaryingSprintLengthDetectorImpl.java
73 73

  
74 74
        // init values
75 75
        List<ResultDetail> resultDetails = new ArrayList<>();
76
        int counter = 0;
76
        int iterationLengthChanged = 0;
77 77
        int numberOfIterations = 0;
78 78

  
79 79
        try {
......
92 92
                    }
93 93

  
94 94
                    if (Math.abs(firstIterationLength - secondIterationLength) >= MAXIMUM_DAYS_DIFFERENCE) {
95
                        counter = counter + 1;
95
                        iterationLengthChanged = iterationLengthChanged + 1;
96 96
                    }
97 97
                    firstIterationLength = secondIterationLength;
98 98
                }
......
106 106

  
107 107
        resultDetails.add(new ResultDetail("Maximum iteration length change", String.valueOf(MAXIMUM_ITERATION_CHANGE)));
108 108
        resultDetails.add(new ResultDetail("Count of iterations", String.valueOf(numberOfIterations)));
109
        resultDetails.add(new ResultDetail("Iteration length changed", String.valueOf(counter)));
109
        resultDetails.add(new ResultDetail("Iteration length changed", String.valueOf(iterationLengthChanged)));
110 110

  
111 111

  
112
        if (counter >= MAXIMUM_ITERATION_CHANGE) {
112
        if (iterationLengthChanged >= MAXIMUM_ITERATION_CHANGE) {
113 113
            resultDetails.add(new ResultDetail("Conclusion", "Iteration length changed significantly too often"));
114 114
        } else {
115 115
            resultDetails.add(new ResultDetail("Conclusion", "Varying iteration length is all right"));
......
118 118
        LOGGER.info(this.antiPattern.getPrintName());
119 119
        LOGGER.info(resultDetails.toString());
120 120

  
121
        return new QueryResultItem(this.antiPattern, (counter >= MAXIMUM_ITERATION_CHANGE), resultDetails);
121
        return new QueryResultItem(this.antiPattern, (iterationLengthChanged >= MAXIMUM_ITERATION_CHANGE), resultDetails);
122 122
    }
123 123
}
src/main/webapp/queries/too_long_sprint.sql
14 14

  
15 15
/* Init project id */
16 16
set @projectId = ?;
17
/* Maximum iteration length in days */
18
set @maxSprintLength = 21;
19 17
/* Exclude first and last iteration? */
20
set @excludeFirstAndLastIteration = false;
18
set @excludeFirstAndLastIteration = true;
21 19
/* Id of first iteration */
22 20
set @idOfFirstIteration = (select id from iteration where iteration.superProjectId = @projectId order by name limit 1);
23 21
/* Id of last iteration */
24 22
set @idOfLastIteration = (select id from iteration where iteration.superProjectId = @projectId order by name desc limit 1);
25
/* Select all too long iterations */
26
select datediff(iteration.endDate, iteration.startDate) as `iterationLength`, if(datediff(iteration.endDate, iteration.startDate) > @maxSprintLength, true, false) as `isTooLongSprint`, iteration.startDate as `iterationStartDate` from iteration where iteration.superProjectId = @projectId and iteration.id != if(@excludeFirstAndLastIteration = true, @idOfFirstIteration, -1) and iteration.id != if(@excludeFirstAndLastIteration = true, @idOfLastIteration, -1) order by iteration.name;
23
/* Select all iterations with their length */
24
select datediff(endDate, startDate) as `iterationLength` from iteration where iteration.superProjectId = @projectId and iteration.id != if(@excludeFirstAndLastIteration = true, @idOfFirstIteration, -1) and iteration.id != if(@excludeFirstAndLastIteration = true, @idOfLastIteration, -1) order by iteration.name;

Také k dispozici: Unified diff