From bc31e3366d2a0a2b09e32b046b87bc188e668c16 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 18 May 2020 14:17:22 +0800 Subject: [PATCH 1/3] calendar heatmap --- .../mapper/ext/ExtLoadTestReportMapper.java | 3 ++ .../mapper/ext/ExtLoadTestReportMapper.xml | 20 +++++++-- .../io/metersphere/dto/DashboardTestDTO.java | 11 +++++ .../controller/PerformanceTestController.java | 6 +++ .../service/PerformanceTestService.java | 9 ++++ frontend/package.json | 3 +- .../performance/home/PerformanceTestHome.vue | 44 ++++++++++++++++--- frontend/src/business/main.js | 2 + frontend/src/common/js/calendar-heatmap.js | 7 +++ 9 files changed, 94 insertions(+), 11 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/dto/DashboardTestDTO.java create mode 100644 frontend/src/common/js/calendar-heatmap.js diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.java index 8393cbe12a..79e6c73667 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.java @@ -1,6 +1,7 @@ package io.metersphere.base.mapper.ext; import io.metersphere.base.domain.LoadTestReport; +import io.metersphere.dto.DashboardTestDTO; import io.metersphere.dto.ReportDTO; import io.metersphere.performance.controller.request.ReportRequest; import org.apache.ibatis.annotations.Param; @@ -16,4 +17,6 @@ public interface ExtLoadTestReportMapper { int appendLine(@Param("testId") String id, @Param("line") String line); LoadTestReport selectByPrimaryKey(String id); + + List selectDashboardTests(@Param("workspaceId") String workspaceId, @Param("startTimestamp") long startTimestamp); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml index cb8e89e0e5..37d15a0676 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml @@ -48,10 +48,22 @@ + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/dto/DashboardTestDTO.java b/backend/src/main/java/io/metersphere/dto/DashboardTestDTO.java new file mode 100644 index 0000000000..72e70350a3 --- /dev/null +++ b/backend/src/main/java/io/metersphere/dto/DashboardTestDTO.java @@ -0,0 +1,11 @@ +package io.metersphere.dto; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class DashboardTestDTO { + private Long date; + private Integer count; +} diff --git a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java index dedd1edc57..3d5ba80c63 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java +++ b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java @@ -7,6 +7,7 @@ import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.dto.DashboardTestDTO; import io.metersphere.dto.LoadTestDTO; import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.service.FileService; @@ -101,4 +102,9 @@ public class PerformanceTestController { .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileOperationRequest.getName() + "\"") .body(bytes); } + + @GetMapping("dashboard/tests") + public List dashboardTests() { + return performanceTestService.dashboardTests(SessionUtils.getCurrentWorkspaceId()); + } } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 9a4c8cbb22..7ee2d6043f 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -8,6 +8,7 @@ import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper; import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; +import io.metersphere.dto.DashboardTestDTO; import io.metersphere.dto.LoadTestDTO; import io.metersphere.i18n.Translator; import io.metersphere.performance.engine.Engine; @@ -23,6 +24,8 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -276,4 +279,10 @@ public class PerformanceTestService { return loadTestMapper.selectByExampleWithBLOBs(example); } + public List dashboardTests(String workspaceId) { + Instant oneYearAgo = Instant.now().plus(-365, ChronoUnit.DAYS); + long startTimestamp = oneYearAgo.toEpochMilli(); + return extLoadTestReportMapper.selectDashboardTests(workspaceId, startTimestamp); + } + } diff --git a/frontend/package.json b/frontend/package.json index 5fdab05896..098e3d0295 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -23,7 +23,8 @@ "vue-i18n": "^8.15.3", "vue-router": "^3.1.3", "vuedraggable": "^2.23.2", - "vuex": "^3.1.2" + "vuex": "^3.1.2", + "vue-calendar-heatmap": "^0.8.4" }, "devDependencies": { "@vue/cli-plugin-babel": "^4.1.0", diff --git a/frontend/src/business/components/performance/home/PerformanceTestHome.vue b/frontend/src/business/components/performance/home/PerformanceTestHome.vue index df55161597..14776eb78a 100644 --- a/frontend/src/business/components/performance/home/PerformanceTestHome.vue +++ b/frontend/src/business/components/performance/home/PerformanceTestHome.vue @@ -1,14 +1,46 @@ diff --git a/frontend/src/business/components/performance/home/PerformanceReportRecentList.vue b/frontend/src/business/components/performance/home/PerformanceReportRecentList.vue new file mode 100644 index 0000000000..74ca92ecfc --- /dev/null +++ b/frontend/src/business/components/performance/home/PerformanceReportRecentList.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/frontend/src/business/components/performance/home/PerformanceTestHome.vue b/frontend/src/business/components/performance/home/PerformanceTestHome.vue index 14776eb78a..c7dd81ba35 100644 --- a/frontend/src/business/components/performance/home/PerformanceTestHome.vue +++ b/frontend/src/business/components/performance/home/PerformanceTestHome.vue @@ -1,11 +1,17 @@