[GitHub] dspavlov commented on a change in pull request #57: IGNITE-9849 Refactor Master trends

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] dspavlov commented on a change in pull request #57: IGNITE-9849 Refactor Master trends

GitBox
dspavlov commented on a change in pull request #57: IGNITE-9849 Refactor Master trends
URL: https://github.com/apache/ignite-teamcity-bot/pull/57#discussion_r229880064
 
 

 ##########
 File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/current/BuildStatisticsSummary.java
 ##########
 @@ -91,122 +96,122 @@ public BuildStatisticsSummary(Integer buildId){
     }
 
     /** Initialize build statistics. */
-    public void initialize(@Nonnull final ITeamcity teamcity) {
-        Build build = teamcity.getBuild(buildId);
+    public void initialize(@Nonnull final IStringCompactor compactor, @Nonnull final ITeamcityIgnited ignitedTeamcity) {
+        if (strIds.isEmpty()) {
+            strIds.put(STATUS_SUCCESS, compactor.getStringId(STATUS_SUCCESS));
+            strIds.put(TC_EXIT_CODE, compactor.getStringId(TC_EXIT_CODE));
+            strIds.put(TC_OOME, compactor.getStringId(TC_OOME));
+            strIds.put(TC_JVM_CRASH, compactor.getStringId(TC_JVM_CRASH));
+            strIds.put(TC_EXECUTION_TIMEOUT, compactor.getStringId(TC_EXECUTION_TIMEOUT));
+        }
+
+        FatBuildCompacted build = ignitedTeamcity.getFatBuild(buildId);
 
         isFakeStub = build.isFakeStub();
 
         if (isFakeStub)
             return;
 
         DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy'T'HH:mm:ss");
-        dateFormat.format(build.getFinishDate());
+
         startDate = dateFormat.format(build.getStartDate());
 
-        testOccurrences = build.testOccurrences;
+        int[] arr = new int[4];
 
-        duration = (build.getFinishDate().getTime() - build.getStartDate().getTime()) / 1000;
+        build.getAllTests().forEach(t -> {
+                if (t.getIgnoredFlag())
+                    arr[0]++;
+                else if (t.getMutedFlag())
+                    arr[1]++;
+                else if (t.status() != strIds.get(STATUS_SUCCESS))
+                    arr[2]++;
 
-        List<BuildRef> snapshotDependencies = getSnapshotDependencies(teamcity, build);
+            arr[3]++;
+        });
 
-        List<BuildRef> snapshotDependenciesWithProblems = getBuildsWithProblems(snapshotDependencies);
+        testOccurrences.ignored = arr[0];
+        testOccurrences.muted = arr[1];
+        testOccurrences.failed = arr[2];
+        testOccurrences.count = arr[3];
+        testOccurrences.passed = testOccurrences.count - testOccurrences.failed - testOccurrences.ignored -
+        testOccurrences.muted;
 
-        problemOccurrenceList = getProblems(teamcity, snapshotDependenciesWithProblems);
+        duration = (build.getFinishDate().getTime() - build.getStartDate().getTime()) / 1000;
 
-        totalProblems = getRes();
-    }
+        List<FatBuildCompacted> snapshotDependencies = getSnapshotDependencies(ignitedTeamcity, buildId);
 
-    private long getExecutionTimeoutCount(String buildTypeId) {
-        return getProblemsStream(buildTypeId).filter(ProblemOccurrence::isExecutionTimeout).count();
-    }
+        List<FatBuildCompacted> snapshotDependenciesWithProblems = getBuildsWithProblems(snapshotDependencies);
 
-    private long getJvmCrashProblemCount(String buildTypeId) {
-        return getProblemsStream(buildTypeId).filter(ProblemOccurrence::isJvmCrash).count();
-    }
+        problemOccurrenceList = getProblems(snapshotDependenciesWithProblems);
 
-    private long getExitCodeProblemsCount(String buildTypeId) {
-        return getProblemsStream(buildTypeId).filter(ProblemOccurrence::isExitCode).count();
+        totalProblems = getBuildTypeProblemsCount();
     }
 
-    private long getOomeProblemCount(String buildTypeId) {
-        return getProblemsStream(buildTypeId).filter(ProblemOccurrence::isOome).count();
+    /**
+     * @param problemName Problem name.
+     */
+    private long getProblemsCount(String problemName) {
+        if (problemOccurrenceList == null)
+            return 0;
+
+        return problemOccurrenceList.stream()
+            .filter(Objects::nonNull)
+            .filter(p -> p.type() == strIds.get(problemName)).count();
     }
 
     /**
      * Problems for all snapshot-dependencies.
      *
-     * @param teamcity Teamcity.
+     * @param builds Builds.
      */
-    private List<ProblemOccurrence> getProblems(@Nonnull final ITeamcity teamcity, List<BuildRef> builds){
-        List<ProblemOccurrence> problemOccurrences = new ArrayList<>();
+    private List<ProblemCompacted> getProblems(List<FatBuildCompacted> builds){
+        List<ProblemCompacted> problemOccurrences = new ArrayList<>();
 
-        for (BuildRef buildRef : builds)
-            problemOccurrences.addAll(teamcity
-                .getProblems(buildRef)
-                .getProblemsNonNull());
+        for (FatBuildCompacted build : builds)
+            problemOccurrences.addAll(
+                build.problems()
+            );
 
         return problemOccurrences;
     }
 
     /**
      * Snapshot-dependencies for build.
      *
-     * @param teamcity Teamcity.
-     * @param buildRef Build reference.
+     * @param ignitedTeamcity ignitedTeamcity.
+     * @param buildId Build Id.
      */
-    private List<BuildRef> getSnapshotDependencies(@Nonnull final ITeamcity teamcity, BuildRef buildRef){
-        FullQueryParams key = new FullQueryParams();
+    private List<FatBuildCompacted> getSnapshotDependencies(@Nonnull final ITeamcityIgnited ignitedTeamcity, Integer buildId){
+        List<FatBuildCompacted> snapshotDependencies = new ArrayList<>();
+        FatBuildCompacted build = ignitedTeamcity.getFatBuild(buildId);
 
-        key.setServerId(teamcity.serverId());
-        key.setBuildId(buildRef.getId());
+        if (build.isComposite()){
 
 Review comment:
   not only composite build can have a dependency. E.g. each build with test depends on the build with compilation

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services