feat(性能测试): 性能测试报告列表支持按时间正序或倒叙排序

https://www.tapd.cn/55049933/prong/stories/view/1155049933001010336
--user=郭雨琦
This commit is contained in:
guoyuqi 2022-11-07 17:27:31 +08:00 committed by xiaomeinvG
parent 2f7bb74e98
commit 057a8a08cc
2 changed files with 40 additions and 2 deletions

View File

@ -156,6 +156,12 @@
#{value} #{value}
</foreach> </foreach>
</when> </when>
<when test="key=='user_name'">
and ltr.user_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise> <otherwise>
and ltr.trigger_mode in and ltr.trigger_mode in
<foreach collection="values" item="value" separator="," open="(" close=")"> <foreach collection="values" item="value" separator="," open="(" close=")">
@ -171,7 +177,17 @@
<if test="reportRequest.orders != null and reportRequest.orders.size() > 0"> <if test="reportRequest.orders != null and reportRequest.orders.size() > 0">
order by order by
<foreach collection="reportRequest.orders" separator="," item="order"> <foreach collection="reportRequest.orders" separator="," item="order">
<choose>
<when test="order.name == 'tps' || order.name == 'test_duration'">
CAST(ltr.${order.name} AS DECIMAL) ${order.type}
</when>
<when test=" order.name == 'max_users' || order.name == 'avg_response_time'">
CAST(ltr.${order.name} AS SIGNED) ${order.type}
</when>
<otherwise>
ltr.${order.name} ${order.type} ltr.${order.name} ${order.type}
</otherwise>
</choose>
</foreach> </foreach>
</if> </if>
</select> </select>

View File

@ -60,12 +60,14 @@
<ms-table-column <ms-table-column
prop="userName" prop="userName"
:field="item" :field="item"
:filters="userFilters"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('report.user_name')" :label="$t('report.user_name')"
show-overflow-tooltip> show-overflow-tooltip>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
prop="maxUsers" prop="maxUsers"
sortable
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
min-width="65" min-width="65"
@ -74,12 +76,14 @@
<ms-table-column <ms-table-column
min-width="100" min-width="100"
:field="item" :field="item"
sortable
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
prop="avgResponseTime" prop="avgResponseTime"
:label="$t('report.response_time')"> :label="$t('report.response_time')">
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
prop="tps" prop="tps"
sortable
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
label="TPS"> label="TPS">
@ -87,6 +91,7 @@
<ms-table-column <ms-table-column
min-width="100" min-width="100"
:field="item" :field="item"
sortable
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
show-overflow-tooltip show-overflow-tooltip
prop="testStartTime" prop="testStartTime"
@ -99,6 +104,7 @@
min-width="100" min-width="100"
show-overflow-tooltip show-overflow-tooltip
:field="item" :field="item"
sortable
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
prop="testEndTime" prop="testEndTime"
:label="$t('report.test_end_time')"> :label="$t('report.test_end_time')">
@ -110,6 +116,7 @@
min-width="90" min-width="90"
prop="testDuration" prop="testDuration"
:field="item" :field="item"
sortable
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('report.test_execute_time')"> :label="$t('report.test_execute_time')">
<template v-slot:default="scope"> <template v-slot:default="scope">
@ -183,6 +190,7 @@ import MsTable from "metersphere-frontend/src/components/table/MsTable";
import {deleteReport, deleteReportBatch, getOverview, getReportTime, renameReport, searchReports} from "@/api/report"; import {deleteReport, deleteReportBatch, getOverview, getReportTime, renameReport, searchReports} from "@/api/report";
import {getProjectVersions, isProjectVersionEnable} from "metersphere-frontend/src/api/version"; import {getProjectVersions, isProjectVersionEnable} from "metersphere-frontend/src/api/version";
import {hasPermission} from "metersphere-frontend/src/utils/permission"; import {hasPermission} from "metersphere-frontend/src/utils/permission";
import {getProjectUsers} from "metersphere-frontend/src/api/user";
export default { export default {
name: "PerformanceTestReportList", name: "PerformanceTestReportList",
@ -203,6 +211,7 @@ export default {
}, },
created() { created() {
this.testId = this.$route.path.split('/')[3]; this.testId = this.$route.path.split('/')[3];
this.getMaintainerOptions();
this.initTableData(); this.initTableData();
this.getVersionOptions(); this.getVersionOptions();
this.checkVersionEnable(); this.checkVersionEnable();
@ -272,6 +281,7 @@ export default {
versionEnable: false, versionEnable: false,
fields: getCustomTableHeader('PERFORMANCE_REPORT_TABLE'), fields: getCustomTableHeader('PERFORMANCE_REPORT_TABLE'),
fieldsWidth: getCustomTableWidth('PERFORMANCE_REPORT_TABLE'), fieldsWidth: getCustomTableWidth('PERFORMANCE_REPORT_TABLE'),
userFilters: [],
}; };
}, },
watch: { watch: {
@ -285,6 +295,15 @@ export default {
} }
}, },
methods: { methods: {
getMaintainerOptions() {
let workspaceId = getCurrentWorkspaceId();
getProjectUsers()
.then(response => {
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});
});
},
handleTimeInfo(report) { handleTimeInfo(report) {
if (report.testStartTime) { if (report.testStartTime) {
let duration = report.testDuration; let duration = report.testDuration;
@ -312,6 +331,9 @@ export default {
} }
}, },
handleOverview(report) { handleOverview(report) {
this.$set(report, 'maxUsers', parseInt(report.maxUsers));
this.$set(report, 'avgResponseTime', parseFloat(report.avgResponseTime));
this.$set(report, 'tps', parseFloat(report.tps));
if (report.status === 'Completed' && !report.maxUsers) { if (report.status === 'Completed' && !report.maxUsers) {
this.loading = getOverview(report.id) this.loading = getOverview(report.id)
.then(response => { .then(response => {
@ -472,7 +494,7 @@ export default {
this.initTableData(); this.initTableData();
this.$refs.renameDialog.close(); this.$refs.renameDialog.close();
}); });
} },
} }
}; };
</script> </script>