use of com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_ISSUE_TYPE_ID in project service-api by reportportal.
the class LaunchDataProviderHandlerImpl method updateFilter.
private Queryable updateFilter(Queryable filter, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user, Map<String, String> params) {
Long launchId = Optional.ofNullable(params.get(LAUNCH_ID_PARAM)).map(ControllerUtils::safeParseLong).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Launch id must be provided for launch based items provider"));
launchAccessValidator.validate(launchId, projectDetails, user);
Queryable launchBasedFilter = Filter.builder().withTarget(TestItem.class).withCondition(FilterCondition.builder().eq(CRITERIA_LAUNCH_ID, String.valueOf(launchId)).build()).build();
// Added to fix performance issue.
List<String> issueTypeLocators = filter.getFilterConditions().stream().map(ConvertibleCondition::getAllConditions).flatMap(List::stream).filter(c -> CRITERIA_ISSUE_TYPE.equals(c.getSearchCriteria()) && !c.isNegative() && Condition.IN.equals(c.getCondition())).map(FilterCondition::getValue).flatMap(c -> Stream.of(c.split(","))).collect(Collectors.toList());
String issueTypeIdsString = issueTypeRepository.getIssueTypeIdsByLocators(issueTypeLocators).stream().map(String::valueOf).collect(Collectors.joining(","));
FilterCondition oldIssueTypeCondition = new FilterCondition(Condition.IN, false, null, CRITERIA_ISSUE_TYPE);
FilterCondition issueTypeIdCondition = new FilterCondition(Condition.IN, false, issueTypeIdsString, CRITERIA_ISSUE_TYPE_ID);
filter.replaceSearchCriteria(oldIssueTypeCondition, issueTypeIdCondition);
return new CompositeFilter(Operator.AND, filter, launchBasedFilter);
}
Aggregations