Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-89421 || Display number of tests related to each Unique Error cluster #2020

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ dependencies {
implementation 'com.epam.reportportal:commons'
implementation 'com.epam.reportportal:plugin-api:5.11.1'
} else {
implementation 'com.github.reportportal:commons-dao:c37b0b0'
implementation 'com.github.reportportal:commons:916f0f8abd'
implementation 'com.github.reportportal:commons-dao:62a9d24'
implementation 'com.github.reportportal:commons:9620556'
implementation 'com.github.reportportal:plugin-api:d1c0f0e'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,19 @@

package com.epam.ta.reportportal.core.launch.cluster;

import static com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID;
import static com.epam.ta.reportportal.ws.converter.converters.ClusterConverter.TO_CLUSTER_INFO;

import com.epam.reportportal.extension.event.GetClusterResourcesEvent;
import com.epam.reportportal.model.launch.cluster.ClusterInfoResource;
import com.epam.reportportal.rules.exception.ErrorType;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.dao.ClusterRepository;
import com.epam.ta.reportportal.entity.cluster.Cluster;
import com.epam.ta.reportportal.entity.launch.Launch;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.converter.PagedResourcesAssembler;
import com.epam.reportportal.rules.exception.ErrorType;
import com.epam.reportportal.model.launch.cluster.ClusterInfoResource;
import java.util.function.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

/**
Expand Down Expand Up @@ -60,21 +56,17 @@ public Cluster getById(Long id) {
@Override
public Iterable<ClusterInfoResource> getResources(Launch launch, Pageable pageable) {

final Pageable pageableWithSort = applySort(pageable);
final Page<Cluster> clusters =
clusterRepository.findAllByLaunchId(launch.getId(), pageableWithSort);
Page<ClusterInfoResource> clusters =
clusterRepository.findAllByLaunchIdWithCount(launch.getId(), pageable);

return getClusterResources(clusters, launch.getId());
}

private Pageable applySort(Pageable pageable) {
final Sort idSort = Sort.by(Sort.Order.asc(CRITERIA_ID));
return PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), idSort);
}

private Iterable<ClusterInfoResource> getClusterResources(Page<Cluster> clusters, Long launchId) {
private Iterable<ClusterInfoResource> getClusterResources(Page<ClusterInfoResource> clusters,
Long launchId) {
final com.epam.ta.reportportal.model.Page<ClusterInfoResource> clustersPage =
PagedResourcesAssembler.pageConverter(TO_CLUSTER_INFO).apply(clusters);
PagedResourcesAssembler.pageConverter(
(Function<ClusterInfoResource, ClusterInfoResource>) c -> c).apply(clusters);
eventPublisher.publishEvent(new GetClusterResourcesEvent(clustersPage.getContent(), launchId));
return clustersPage;
}
Expand Down
Loading