Skip to content

Commit

Permalink
EPMRPP-96317 extend analyzer statistics gatherer (#2118)
Browse files Browse the repository at this point in the history
  • Loading branch information
grabsefx authored Dec 10, 2024
1 parent c3709cf commit 95850b5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
public interface DefectUpdateStatisticsService {

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

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

void saveUserAnalyzedDefectStatistics(int size, Long projectId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ public DefectUpdateStatisticsServiceImpl(
*/
@Override
public void saveAnalyzedDefectStatistics(int amountToAnalyze, int analyzedAmount,
int userAnalyzedAmount, Long projectId) {
int userAnalyzedAmount, int skipped, int passed, 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 @@ -98,6 +100,18 @@ 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,
projectId);
}

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

private boolean isAnalyticsGatheringAllowed() {
return serverSettingsRepository.selectServerSettings()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
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 @@ -147,9 +150,23 @@ private void analyzeItemsPartition(Launch launch, List<Long> testItemIds,
analyzedMap.forEach(
(key, value) -> updateTestItems(key, value, toAnalyze, launch.getProjectId()));
}

// 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();

defectUpdateStatisticsService
.saveAnalyzedDefectStatistics(amountToAnalyze, analyzedMap.size(), 0, rq.getProjectId());
.saveAutoAnalyzedDefectStatistics(amountToAnalyze, analyzedMap.size(), skipped, passed,
rq.getProjectId());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.core.analytics.DefectUpdateStatisticsService;
import com.epam.ta.reportportal.core.analyzer.auto.client.AnalyzerServiceClient;
import com.epam.ta.reportportal.core.analyzer.auto.impl.AnalyzerUtils;
import com.epam.ta.reportportal.core.analyzer.auto.impl.LogIndexerService;
import com.epam.ta.reportportal.core.events.MessageBus;
Expand Down Expand Up @@ -161,8 +160,8 @@ public List<Issue> defineTestItemsIssues(ReportPortalUser.ProjectDetails project
List<Long> itemsForIndexRemove = new ArrayList<>();

// save data for analytics
defectUpdateStatisticsService.saveAnalyzedDefectStatistics(definitions.size(), 0,
definitions.size(), projectDetails.getProjectId());
defectUpdateStatisticsService.saveUserAnalyzedDefectStatistics(definitions.size(),
projectDetails.getProjectId());

definitions.forEach(issueDefinition -> {
try {
Expand Down

0 comments on commit 95850b5

Please sign in to comment.