Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 81584b47

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

Too long sprint final refactor

Zobrazit rozdíly:

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/TooLongSprintDetectorImpl.java
5 5
import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
6 6
import cz.zcu.fav.kiv.antipatterndetectionapp.model.QueryResultItem;
7 7
import cz.zcu.fav.kiv.antipatterndetectionapp.model.ResultDetail;
8
import cz.zcu.fav.kiv.antipatterndetectionapp.utils.Utils;
9 8
import org.slf4j.Logger;
10 9
import org.slf4j.LoggerFactory;
11 10

  
12 11
import java.sql.ResultSet;
13 12
import java.sql.SQLException;
13
import java.util.ArrayList;
14 14
import java.util.List;
15 15

  
16 16
public class TooLongSprintDetectorImpl extends AntiPatternDetector {
......
26 26
                    "beginning and at the end of the project, but it should not " +
27 27
                    "change in the already started project).");
28 28

  
29
    private final String sqlFileName = "too_long_sprint.sql";
30

  
31
    /**
32
     * Settings
33
     */
34
    private final float DIVISION_OF_TOO_LONG_ITERATIONS = (float) 1/3;
29
    private final String SQL_FILE_NAME = "too_long_sprint.sql";
35 30

  
36 31

  
37 32
    @Override
......
41 36

  
42 37
    @Override
43 38
    public String getAntiPatternSqlFileName() {
44
        return this.sqlFileName;
39
        return this.SQL_FILE_NAME;
45 40
    }
46 41

  
47 42
    /**
......
50 45
     *      2) odebrat první a poslední iteraci( ty mohou být z důvodu nastartování projektu dlouhé)
51 46
     *      3) zjistit jejich délku (rozdíl mezi start date a end date)
52 47
     *      4) pokud iterace přesháne délku 21 dní (3 týdny), tak jsou označeny jako moc dlouhé
53
     *      5) pokud je delší více jak 1/3 ze všech sledovaných iterací, tak je anti pattern detekován
54
     * @param project analyzovaný project
55
     * @param databaseConnection    databázové připojení
56
     * @param queries   list sql dotazů
48
     *      5) pokud je nalezena jedna nebo více iterací jako dlouhé, tak je anti pattern detekován
49
     *
50
     * @param project            analyzovaný project
51
     * @param databaseConnection databázové připojení
52
     * @param queries            list sql dotazů
57 53
     * @return výsledek detekce
58 54
     */
59 55
    @Override
......
62 58
        int numberOfLongIterations = 0;
63 59
        int totalCountOfIteration = 0;
64 60

  
61
        // get results from sql queries
65 62
        try {
66 63
            ResultSet rs = databaseConnection.executeQueries(project, queries);
67 64
            if (rs != null) {
......
75 72
            }
76 73

  
77 74
        } catch (SQLException e) {
78
            e.printStackTrace();
75
            LOGGER.error("Cannot read results from db");
76
            List<ResultDetail> resultDetails = new ArrayList<>();
77
            resultDetails.add(new ResultDetail("Problem in reading database", e.toString()));
78
            return new QueryResultItem(this.antiPattern, true, resultDetails);
79 79
        }
80 80

  
81
        int maxIterationLimit = Math.round(totalCountOfIteration * DIVISION_OF_TOO_LONG_ITERATIONS);
81
        List<ResultDetail> resultDetails = new ArrayList<>();
82
        resultDetails.add(new ResultDetail("Count of iterations", String.valueOf(totalCountOfIteration)));
83
        resultDetails.add(new ResultDetail("Number of too long iterations", String.valueOf(numberOfLongIterations)));
84
        if (numberOfLongIterations >= 1) {
85
            resultDetails.add(new ResultDetail("Conclusion", "One or more iteration is too long"));
86
        } else {
87
            resultDetails.add(new ResultDetail("Conclusion", "All iterations in limit"));
88
        }
82 89

  
83
        List<ResultDetail> resultDetails = Utils.createResultDetailsList(
84
                new ResultDetail("Project id", project.getId().toString()),
85
                new ResultDetail("Max Iteration limit", String.valueOf(maxIterationLimit)),
86
                new ResultDetail("Count of iterations", String.valueOf(totalCountOfIteration)),
87
                new ResultDetail("Number of too long iterations", String.valueOf(numberOfLongIterations)),
88
                new ResultDetail("Is detected", String.valueOf(numberOfLongIterations >= maxIterationLimit)));
89 90
        LOGGER.info(this.antiPattern.getPrintName());
90 91
        LOGGER.info(resultDetails.toString());
91 92

  
92
        return new QueryResultItem(this.antiPattern, numberOfLongIterations >= maxIterationLimit, resultDetails);
93
        return new QueryResultItem(this.antiPattern, numberOfLongIterations >= 1, resultDetails);
93 94
    }
94 95
}
src/main/resources/queries/too_long_sprint.sql
15 15
/* Init project id */
16 16
set @projectId = ?;
17 17
/* Maximum iteration length in days */
18
set @maxSprintLength = 20;
18
set @maxSprintLength = 21;
19 19
/* Exclude first and last iteration? */
20 20
set @excludeFirstAndLastIteration = false;
21 21
/* Id of first iteration */

Také k dispozici: Unified diff