Skip to content

Commit

Permalink
feat:add queryPlanStatistic for backend (#335)
Browse files Browse the repository at this point in the history
Co-authored-by: yushuwang <[email protected]>
  • Loading branch information
wildeslam and yushuwang authored Dec 8, 2023
1 parent f8676b9 commit bba96ac
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 9 deletions.
2 changes: 1 addition & 1 deletion arex-web-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<parent>
<artifactId>arex-web</artifactId>
<groupId>com.arextest</groupId>
<version>0.6.0.11</version>
<version>0.6.0.12</version>
</parent>
<profiles>
<profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void addInterceptors(InterceptorRegistry registry) {
defaultPatterns.add("/api/desensitization/listJar");
defaultPatterns.add("/api/system/config/list");
defaultPatterns.add("/api/config/comparison/summary/queryConfigOfCategory");
defaultPatterns.add("/api/report/queryPlanStatistic");

// exclude configuration services
defaultPatterns.add("/api/config/**");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import com.arextest.web.model.contract.contracts.QueryPlanFailCaseRequestType;
import com.arextest.web.model.contract.contracts.QueryPlanItemStatisticsRequestType;
import com.arextest.web.model.contract.contracts.QueryPlanItemStatisticsResponseType;
import com.arextest.web.model.contract.contracts.QueryPlanStatisticRequestType;
import com.arextest.web.model.contract.contracts.QueryPlanStatisticResponseType;
import com.arextest.web.model.contract.contracts.QueryPlanStatisticsRequestType;
import com.arextest.web.model.contract.contracts.QueryPlanStatisticsResponseType;
import com.arextest.web.model.contract.contracts.QueryReplayCaseRequestType;
Expand Down Expand Up @@ -199,7 +201,18 @@ public Response queryPlanStatistics(@RequestBody QueryPlanStatisticsRequestType
return ResponseUtils.errorResponse("invalid paging parameter",
ResponseCode.REQUESTED_PARAMETER_INVALID);
}
QueryPlanStatisticsResponseType response = queryPlanStatisticsService.planStatistic(request);
QueryPlanStatisticsResponseType response = queryPlanStatisticsService.planStatistics(request);
return ResponseUtils.successResponse(response);
}

@PostMapping("/queryPlanStatistic")
@ResponseBody
public Response queryPlanStatistic(@RequestBody QueryPlanStatisticRequestType request) {
if (request == null) {
return ResponseUtils.errorResponse("invalid paging parameter",
ResponseCode.REQUESTED_PARAMETER_INVALID);
}
QueryPlanStatisticResponseType response = queryPlanStatisticsService.planStatistic(request);
return ResponseUtils.successResponse(response);
}

Expand Down
2 changes: 1 addition & 1 deletion arex-web-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
<parent>
<artifactId>arex-web</artifactId>
<groupId>com.arextest</groupId>
<version>0.6.0.11</version>
<version>0.6.0.12</version>
</parent>
</project>
2 changes: 1 addition & 1 deletion arex-web-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@
<parent>
<artifactId>arex-web</artifactId>
<groupId>com.arextest</groupId>
<version>0.6.0.11</version>
<version>0.6.0.12</version>
</parent>
</project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.arextest.web.core.business;

import com.arextest.web.core.repository.mongo.ReportPlanStatisticRepositoryImpl;
import com.arextest.web.model.contract.contracts.QueryPlanStatisticRequestType;
import com.arextest.web.model.contract.contracts.QueryPlanStatisticResponseType;
import com.arextest.web.model.contract.contracts.QueryPlanStatisticsRequestType;
import com.arextest.web.model.contract.contracts.QueryPlanStatisticsResponseType;
import com.arextest.web.model.contract.contracts.common.CaseCount;
import com.arextest.web.model.contract.contracts.common.PlanStatistic;
import com.arextest.web.model.dto.ReportPlanStatisticDto;
import com.arextest.web.model.mapper.PlanMapper;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -24,7 +28,7 @@ public class QueryPlanStatisticsService {
@Autowired
private CaseCountService caseCountService;

public QueryPlanStatisticsResponseType planStatistic(QueryPlanStatisticsRequestType request) {
public QueryPlanStatisticsResponseType planStatistics(QueryPlanStatisticsRequestType request) {
QueryPlanStatisticsResponseType response = new QueryPlanStatisticsResponseType();

Pair<List<ReportPlanStatisticDto>, Long> result = planStatisticRepository.pageQueryPlanStatistic(
Expand Down Expand Up @@ -58,4 +62,27 @@ public QueryPlanStatisticsResponseType planStatistic(QueryPlanStatisticsRequestT
response.setPlanStatisticList(planStatistics);
return response;
}

public QueryPlanStatisticResponseType planStatistic(QueryPlanStatisticRequestType request) {
QueryPlanStatisticResponseType response = new QueryPlanStatisticResponseType();
ReportPlanStatisticDto reportPlanStatisticDto = planStatisticRepository.findByPlanId(request.getPlanId());
if (reportPlanStatisticDto == null) {
return response;
}
Map<String, CaseCount> caseCountMap = caseCountService.calculateCaseCountsByPlanIds(Collections.singletonList(request.getPlanId()));
if (caseCountMap.isEmpty() || !caseCountMap.containsKey(request.getPlanId())) {
return response;
}
CaseCount caseCount = caseCountMap.get(request.getPlanId());
reportPlanStatisticDto.setTotalCaseCount(caseCount.getTotalCaseCount());
reportPlanStatisticDto.setErrorCaseCount(caseCount.getErrorCaseCount());
reportPlanStatisticDto.setSuccessCaseCount(caseCount.getSuccessCaseCount());
reportPlanStatisticDto.setFailCaseCount(caseCount.getFailCaseCount());
reportPlanStatisticDto.setWaitCaseCount(caseCount.getTotalCaseCount() - caseCount.getReceivedCaseCount());
reportPlanStatisticDto.setTotalOperationCount(caseCount.getTotalOperationCount());
reportPlanStatisticDto.setSuccessOperationCount(caseCount.getSuccessOperationCount());
PlanStatistic planStatistic = PlanMapper.INSTANCE.contractFromDto(reportPlanStatisticDto);
response.setPlanStatistic(planStatistic);
return response;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private QueryPlanStatisticsResponseType queryPlan(String appId, String planId) {
request.setPageSize(1);
request.setPageIndex(1);
request.setPlanId(planId);
return queryPlanStatisticsService.planStatistic(request);
return queryPlanStatisticsService.planStatistics(request);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion arex-web-model-contract/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<parent>
<artifactId>arex-web</artifactId>
<groupId>com.arextest</groupId>
<version>0.6.0.11</version>
<version>0.6.0.12</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.arextest.web.model.contract.contracts;

import lombok.Data;

/**
* @author wildeslam.
* @create 2023/12/8 16:37
*/
@Data
public class QueryPlanStatisticRequestType {

private String appId;
private String planId;
private String imageId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.arextest.web.model.contract.contracts;

import com.arextest.web.model.contract.contracts.common.PlanStatistic;
import lombok.Data;

/**
* @author wildeslam.
* @create 2023/12/8 16:41
*/
@Data
public class QueryPlanStatisticResponseType {
private PlanStatistic planStatistic;
}
2 changes: 1 addition & 1 deletion arex-web-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
<parent>
<artifactId>arex-web</artifactId>
<groupId>com.arextest</groupId>
<version>0.6.0.11</version>
<version>0.6.0.12</version>
</parent>
</project>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,5 +386,5 @@

<url>https://github.com/arextest/arex-report</url>

<version>0.6.0.11</version>
<version>0.6.0.12</version>
</project>

0 comments on commit bba96ac

Please sign in to comment.