Skip to content

Commit

Permalink
EPMRPP-96317 fix count (#2126)
Browse files Browse the repository at this point in the history
  • Loading branch information
grabsefx authored Dec 19, 2024
1 parent d909cdb commit 02210a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
public interface DefectUpdateStatisticsService {

void saveAnalyzedDefectStatistics(int amountToAnalyze, int analyzedAmount, int userAnalyzedAmount,
int skipped, int passed,
Long projectId);
int skipped, Long projectId);

void saveAutoAnalyzedDefectStatistics(int amountToAnalyze, int analyzedAmount, int skipped,
int passed, Long projectId);
Long projectId);

void saveUserAnalyzedDefectStatistics(int size, Long projectId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,13 @@ public DefectUpdateStatisticsServiceImpl(
*/
@Override
public void saveAnalyzedDefectStatistics(int amountToAnalyze, int analyzedAmount,
int userAnalyzedAmount, int skipped, int passed, Long projectId) {
int userAnalyzedAmount, int skipped, Long projectId) {
if (isAnalyticsGatheringAllowed()) {
var map = getMapWithCommonParameters(projectId);
map.put("sentToAnalyze", amountToAnalyze);
map.put("analyzed", analyzedAmount);
map.put("userAnalyzed", userAnalyzedAmount);
map.put("skipped", skipped);
map.put("passed", passed);

AnalyticsData ad = new AnalyticsData();
ad.setType(DEFECT_UPDATE_STATISTICS.name());
Expand All @@ -102,14 +101,14 @@ public void saveAnalyzedDefectStatistics(int amountToAnalyze, int analyzedAmount

@Override
public void saveAutoAnalyzedDefectStatistics(int amountToAnalyze, int analyzedAmount, int skipped,
int passed, Long projectId) {
this.saveAnalyzedDefectStatistics(amountToAnalyze, analyzedAmount, 0, skipped, passed,
Long projectId) {
this.saveAnalyzedDefectStatistics(amountToAnalyze, analyzedAmount, 0, skipped,
projectId);
}

@Override
public void saveUserAnalyzedDefectStatistics(int userAnalyzed, Long projectId) {
this.saveAnalyzedDefectStatistics(userAnalyzed, 0, userAnalyzed, 0, 0, projectId);
this.saveAnalyzedDefectStatistics(userAnalyzed, 0, userAnalyzed, 0, projectId);
}

private boolean isAnalyticsGatheringAllowed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
package com.epam.ta.reportportal.core.analyzer.auto.impl;

import static com.epam.ta.reportportal.core.analyzer.auto.impl.AnalyzerStatusCache.AUTO_ANALYZER_KEY;
import static com.epam.ta.reportportal.entity.enums.StatusEnum.PASSED;
import static com.epam.ta.reportportal.entity.enums.StatusEnum.SKIPPED;
import static com.epam.ta.reportportal.util.Predicates.ITEM_CAN_BE_INDEXED;
import static com.epam.ta.reportportal.ws.converter.converters.TestItemConverter.TO_ACTIVITY_RESOURCE;
import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toList;
Expand Down Expand Up @@ -48,6 +46,7 @@
import com.epam.ta.reportportal.ws.converter.builders.IssueEntityBuilder;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -119,7 +118,8 @@ public void runAnalyzers(Launch launch, List<Long> testItemIds, AnalyzerConfig a
analyzerStatusCache.analyzeStarted(AUTO_ANALYZER_KEY, launch.getId(), launch.getProjectId());
Optional<Long> previousLaunchId = findPreviousLaunchId(launch, analyzerConfig);
Iterables.partition(testItemIds, itemsBatchSize)
.forEach(partition -> analyzeItemsPartition(launch, partition, analyzerConfig, previousLaunchId));
.forEach(partition -> analyzeItemsPartition(launch, partition, analyzerConfig,
previousLaunchId));
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
} finally {
Expand Down Expand Up @@ -153,19 +153,14 @@ private void analyzeItemsPartition(Launch launch, List<Long> testItemIds,

// save data for analytics
int skipped = (int) toAnalyze.stream()
.filter(ti -> rq.getTestItems().stream()
.anyMatch(idxTi -> idxTi.getTestItemId().equals(ti.getItemResults().getItemId())))
.filter(ti -> ti.getItemResults().getStatus().equals(SKIPPED))
.count();
int passed = (int) toAnalyze.stream()
.filter(ti -> rq.getTestItems().stream()
.anyMatch(idxTi -> idxTi.getTestItemId().equals(ti.getItemResults().getItemId())))
.filter(ITEM_CAN_BE_INDEXED)
.filter(ti -> ti.getItemResults().getStatus().equals(PASSED))
.count();
int analyzedAmount = (int) analyzedMap.values().stream()
.mapToLong(Collection::size)
.sum();

defectUpdateStatisticsService
.saveAutoAnalyzedDefectStatistics(amountToAnalyze, analyzedMap.size(), skipped, passed,
.saveAutoAnalyzedDefectStatistics(amountToAnalyze, analyzedAmount, skipped,
rq.getProjectId());
});
}
Expand Down Expand Up @@ -256,8 +251,7 @@ private RelevantItemInfo updateIssueFromRelevantItem(IssueEntity issue, TestItem
}

/**
*
* @param launch Analyzed launch
* @param launch Analyzed launch
* @param analyzerConfig Current analyzer config
* @return Id of previous launch. Required only for PREVIOUS_LAUNCH option.
*/
Expand Down

0 comments on commit 02210a4

Please sign in to comment.