提交 17d627af 编写于 作者: C Captain.B

Merge remote-tracking branch 'origin/dev' into dev

...@@ -10,11 +10,13 @@ import io.metersphere.commons.constants.RoleConstants; ...@@ -10,11 +10,13 @@ import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.DashboardTestDTO;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@RestController @RestController
...@@ -34,6 +36,11 @@ public class APIReportController { ...@@ -34,6 +36,11 @@ public class APIReportController {
return apiReportService.recentTest(request); return apiReportService.recentTest(request);
} }
@GetMapping("/list/{testId}")
public List<APIReportResult> listByTestId(@PathVariable String testId) {
return apiReportService.listByTestId(testId);
}
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<APIReportResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryAPIReportRequest request) { public Pager<List<APIReportResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryAPIReportRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
...@@ -51,4 +58,10 @@ public class APIReportController { ...@@ -51,4 +58,10 @@ public class APIReportController {
apiReportService.delete(request); apiReportService.delete(request);
} }
@GetMapping("dashboard/tests")
public List<DashboardTestDTO> dashboardTests() {
return apiReportService.dashboardTests(SessionUtils.getCurrentWorkspaceId());
}
} }
...@@ -10,9 +10,12 @@ import io.metersphere.base.domain.ApiTestWithBLOBs; ...@@ -10,9 +10,12 @@ import io.metersphere.base.domain.ApiTestWithBLOBs;
import io.metersphere.base.mapper.ApiTestReportMapper; import io.metersphere.base.mapper.ApiTestReportMapper;
import io.metersphere.base.mapper.ext.ExtApiTestReportMapper; import io.metersphere.base.mapper.ext.ExtApiTestReportMapper;
import io.metersphere.commons.constants.APITestStatus; import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.dto.DashboardTestDTO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
...@@ -62,4 +65,11 @@ public class APIReportService { ...@@ -62,4 +65,11 @@ public class APIReportService {
report.setStatus(APITestStatus.Completed.name()); report.setStatus(APITestStatus.Completed.name());
apiTestReportMapper.insert(report); apiTestReportMapper.insert(report);
} }
public List<DashboardTestDTO> dashboardTests(String workspaceId) {
Instant oneYearAgo = Instant.now().plus(-365, ChronoUnit.DAYS);
long startTimestamp = oneYearAgo.toEpochMilli();
return extApiTestReportMapper.selectDashboardTests(workspaceId, startTimestamp);
}
} }
...@@ -3,6 +3,7 @@ package io.metersphere.base.mapper.ext; ...@@ -3,6 +3,7 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.APIReportResult; import io.metersphere.api.dto.APIReportResult;
import io.metersphere.api.dto.QueryAPIReportRequest; import io.metersphere.api.dto.QueryAPIReportRequest;
import io.metersphere.dto.ApiReportDTO; import io.metersphere.dto.ApiReportDTO;
import io.metersphere.dto.DashboardTestDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -15,4 +16,6 @@ public interface ExtApiTestReportMapper { ...@@ -15,4 +16,6 @@ public interface ExtApiTestReportMapper {
APIReportResult get(@Param("id") String id); APIReportResult get(@Param("id") String id);
List<DashboardTestDTO> selectDashboardTests(@Param("workspaceId") String workspaceId, @Param("startTimestamp") long startTimestamp);
} }
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
</select> </select>
<select id="listByTestId" resultMap="BaseResultMap"> <select id="listByTestId" resultMap="BaseResultMap">
SELECT c, SELECT t.name AS test_name,
r.name, r.description, r.id, r.test_id, r.create_time, r.update_time, r.status, r.name, r.description, r.id, r.test_id, r.create_time, r.update_time, r.status,
project.name AS project_name project.name AS project_name
FROM api_test_report r JOIN api_test t ON r.test_id = t.id FROM api_test_report r JOIN api_test t ON r.test_id = t.id
...@@ -50,4 +50,16 @@ ...@@ -50,4 +50,16 @@
ORDER BY r.update_time DESC ORDER BY r.update_time DESC
</select> </select>
<select id="selectDashboardTests" resultType="io.metersphere.dto.DashboardTestDTO">
SELECT create_time AS date, count(api_test_report.id) AS count,
date_format(from_unixtime(create_time / 1000), '%Y-%m-%d') AS x
FROM api_test_report
WHERE test_id IN (SELECT api_test.id
FROM api_test
JOIN project ON api_test.project_id = project.id
WHERE workspace_id = #{workspaceId,jdbcType=VARCHAR})
AND create_time > #{startTimestamp}
GROUP BY x
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
return '/api/' + item.id; return '/api/' + item.id;
}, },
router: function (item) { router: function (item) {
return {name: 'fucPlan', params: {projectId: item.id, projectName: item.name}} return {name: 'ApiTestList', params: {projectId: item.id, projectName: item.name}}
} }
}, },
testRecent: { testRecent: {
......
<template> <template>
<ms-container> <ms-container>
<ms-main-container> <ms-main-container v-loading="result.loading">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<ms-api-test-recent-list/> <ms-api-test-recent-list/>
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
<ms-api-report-recent-list/> <ms-api-report-recent-list/>
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<ms-test-heatmap :values="values"></ms-test-heatmap>
</el-row>
</ms-main-container> </ms-main-container>
</ms-container> </ms-container>
...@@ -19,13 +22,34 @@ ...@@ -19,13 +22,34 @@
import MsMainContainer from "../../common/components/MsMainContainer"; import MsMainContainer from "../../common/components/MsMainContainer";
import MsApiTestRecentList from "./ApiTestRecentList"; import MsApiTestRecentList from "./ApiTestRecentList";
import MsApiReportRecentList from "./ApiReportRecentList"; import MsApiReportRecentList from "./ApiReportRecentList";
import MsTestHeatmap from "../../common/components/MsTestHeatmap";
export default { export default {
name: "ApiTestHome", name: "ApiTestHome",
components: {MsApiReportRecentList, MsApiTestRecentList, MsMainContainer, MsContainer}
components: {MsTestHeatmap, MsApiReportRecentList, MsApiTestRecentList, MsMainContainer, MsContainer},
data() {
return {
values: [],
result: {},
}
},
mounted() {
this.result = this.$get('/api/report/dashboard/tests', response => {
this.values = response.data;
});
},
} }
</script> </script>
<style scoped> <style scoped>
.el-row {
margin-bottom: 20px;
}
.el-row:last-child {
margin-bottom: 0;
}
</style> </style>
...@@ -59,11 +59,11 @@ ...@@ -59,11 +59,11 @@
} }
}, },
beforeRouteEnter(to, from, next) { watch: {
next(self => { '$route'(to) {
self.testId = to.params.testId; this.testId = to.params.testId;
self.search(); this.search();
}); }
}, },
methods: { methods: {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<el-button type="success" plain @click="search">{{$t('api_report.title')}}</el-button> <el-button type="success" plain @click="search">{{$t('api_report.title')}}</el-button>
<el-dialog :title="$t('api_report.title')" :visible.sync="reportVisible"> <el-dialog :title="$t('api_report.title')" :visible.sync="reportVisible">
<el-table :data="tableData"> <el-table :data="tableData" v-loading="result.loading">
<el-table-column :label="$t('commons.name')" width="150" show-overflow-tooltip> <el-table-column :label="$t('commons.name')" width="150" show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-link type="info" @click="link(scope.row)">{{ scope.row.name }}</el-link> <el-link type="info" @click="link(scope.row)">{{ scope.row.name }}</el-link>
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
components: {MsApiReportStatus}, components: {MsApiReportStatus},
props: ["testId"],
data() { data() {
return { return {
reportVisible: false, reportVisible: false,
...@@ -50,7 +52,8 @@ ...@@ -50,7 +52,8 @@
search() { search() {
this.reportVisible = true; this.reportVisible = true;
this.result = this.$get("/api/report/recent/99", response => { let url = "/api/report/list/" + this.testId;
this.result = this.$get(url, response => {
this.tableData = response.data; this.tableData = response.data;
}); });
}, },
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<el-button type="warning" plain @click="cancel">{{$t('commons.cancel')}}</el-button> <el-button type="warning" plain @click="cancel">{{$t('commons.cancel')}}</el-button>
<ms-api-report-dialog/> <ms-api-report-dialog :test-id="id" v-if="id"/>
</el-row> </el-row>
</el-header> </el-header>
<ms-api-scenario-config :scenarios="test.scenarioDefinition" ref="config"/> <ms-api-scenario-config :scenarios="test.scenarioDefinition" ref="config"/>
......
...@@ -63,11 +63,11 @@ ...@@ -63,11 +63,11 @@
} }
}, },
beforeRouteEnter(to, from, next) { watch: {
next(self => { '$route'(to) {
self.projectId = to.params.projectId; this.projectId = to.params.projectId;
self.search(); this.search();
}); }
}, },
methods: { methods: {
......
...@@ -34,7 +34,9 @@ ...@@ -34,7 +34,9 @@
}, },
watch: { watch: {
'$route'(to) { '$route'(to) {
this.activeIndex = to.matched[0].path; if (to.matched.length > 0) {
this.activeIndex = to.matched[0].path;
}
this.handleSelect(this.activeIndex); this.handleSelect(this.activeIndex);
} }
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册