Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: task summary reports view in issue sidebar (#15063)

boojackebf738a7767d
diff --git a/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue b/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue
index e70faa167e..7399e02c01 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue
@@ -2,6 +2,7 @@
<div class="flex flex-col gap-y-3 py-2 px-3">
<VCSInfo />
<ReleaseInfo />
+ <TaskCheckSummarySection />
<ReviewSection />
<IssueLabels />
@@ -20,5 +21,6 @@ import IssueLabels from "./IssueLabels.vue";
import PreBackupSection from "./PreBackupSection";
import ReleaseInfo from "./ReleaseInfo.vue";
import ReviewSection from "./ReviewSection";
+import TaskCheckSummarySection from "./TaskCheckSummarySection";
import VCSInfo from "./VCSInfo.vue";
</script>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/AffectedRowsView.vue b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/AffectedRowsView.vue
new file mode 100644
index 0000000000..cec250b9b3
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/AffectedRowsView.vue
@@ -0,0 +1,110 @@
+<template>
+ <NPopover v-if="shouldShow" trigger="hover" placement="bottom">
+ <template #trigger>
+ <NTag round>
+ <span class="text-gray-400 text-sm mr-1">{{
+ $t("task.check-type.affected-rows.self")
+ }}</span>
+ <span class="text-sm font-medium">
+ {{ affectedRows }}
+ </span>
+ </NTag>
+ </template>
+ <div
+ class="flex flex-col justify-start items-start w-72 max-h-128 overflow-auto"
+ >
+ <p class="text-sm text-gray-400">
+ {{ $t("task.check-type.affected-rows.description") }}
+ </p>
+ <div class="w-full flex flex-col mt-1 gap-y-1">
+ <div
+ class="w-full flex flex-row justify-between items-center gap-1 group hover:opacity-90 cursor-pointer"
+ v-for="task in affectedTasks"
+ :key="task.name"
+ @click="onClickTask(task)"
+ >
+ <span class="group-hover:underline truncate">
+ {{ task.title }}
+ </span>
+ <span
+ class="shrink-0"
+ :class="
+ !affectedTaskMap.get(task.name) ? 'opacity-80' : 'font-medium'
+ "
+ >
+ {{ affectedTaskMap.get(task.name) }}
+ </span>
+ </div>
+ </div>
+ </div>
+ </NPopover>
+</template>
+
+<script setup lang="ts">
+import { NTag, NPopover } from "naive-ui";
+import { computed } from "vue";
+import { useIssueContext } from "@/components/IssueV1/logic";
+import { type PlanCheckRun } from "@/types/proto/v1/plan_service";
+import type { Task } from "@/types/proto/v1/rollout_service";
+import { flattenTaskV1List } from "@/utils";
+
+const props = defineProps<{
+ taskSummaryReportMap: Map<string, PlanCheckRun>;
+}>();
+
+const { issue, events } = useIssueContext();
+
+const tasks = computed(() => flattenTaskV1List(issue.value.rolloutEntity));
+
+const affectedTaskMap = computed(() => {
+ const tempMap = new Map<string, number>();
+ props.taskSummaryReportMap.forEach((planCheckRun, task) => {
+ if (
+ planCheckRun.results.every(
+ (result) => result.sqlSummaryReport?.affectedRows === undefined
+ )
+ ) {
+ return;
+ }
+
+ const count = planCheckRun.results.reduce(
+ (acc, result) => acc + (result.sqlSummaryReport?.affectedRows || 0),
+ 0
+ );
+ tempMap.set(task, count);
+ });
+ return new Map(Array.from(tempMap.entries()).sort((a, b) => b[1] - a[1]));
+});
+
+const affectedTasks = computed(
+ () =>
+ Array.from(affectedTaskMap.value.keys())
+ .map((task) => tasks.value.find((t) => t.name === task))
+ .filter((task) => task) as Task[]
+);
+
+const summaryReportResults = computed(() =>
+ Array.from(props.taskSummaryReportMap.values()).flatMap(
+ (report) => report.results
+ )
+);
+
+const affectedRows = computed(() =>
+ summaryReportResults.value.reduce(
+ (acc, result) => acc + (result.sqlSummaryReport?.affectedRows || 0),
+ 0
+ )
+);
+
+const shouldShow = computed(() =>
+ summaryReportResults.value.some(
+ (result) => result.sqlSummaryReport?.affectedRows !== undefined
+ )
+);
+
+const onClickTask = (task: Task) => {
+ events.emit("select-task", { task });
+};
+
+defineExpose({ shouldShow });
+</script>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/FailedTasksView.vue b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/FailedTasksView.vue
new file mode 100644
index 0000000000..b51cce867e
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/FailedTasksView.vue
@@ -0,0 +1,81 @@
+<template>
+ <NPopover v-if="shouldShow" trigger="hover" placement="bottom">
+ <template #trigger>
+ <NTag round type="error">
+ <span class="text-red-400 text-sm mr-1">{{ $t("common.errors") }}</span>
+ <span class="text-sm font-medium">
+ {{ failedTasks.length }}
+ </span>
+ </NTag>
+ </template>
+ <div
+ class="flex flex-col justify-start items-start w-72 max-h-128 overflow-auto"
+ >
+ <div class="w-full flex flex-col mt-1 gap-y-2 divide-y">
+ <div
+ class="w-full group hover:opacity-90 cursor-pointer"
+ v-for="task in failedTasks"
+ :key="task.name"
+ @click="onClickTask(task)"
+ >
+ <p class="group-hover:underline truncate">
+ {{ task.title }}
+ </p>
+ <p class="text-xs leading-4 text-error line-clamp-2">
+ {{ failedMessageOfTask(task.name) }}
+ </p>
+ </div>
+ </div>
+ </div>
+ </NPopover>
+</template>
+
+<script setup lang="ts">
+import { NTag, NPopover } from "naive-ui";
+import { computed } from "vue";
+import { useIssueContext } from "@/components/IssueV1";
+import {
+ PlanCheckRun_Result_Status,
+ type PlanCheckRun,
+} from "@/types/proto/v1/plan_service";
+import type { Task } from "@/types/proto/v1/rollout_service";
+import { flattenTaskV1List } from "@/utils";
+
+const props = defineProps<{
+ taskSummaryReportMap: Map<string, PlanCheckRun>;
+}>();
+
+const { issue, events } = useIssueContext();
+
+const tasks = computed(() => flattenTaskV1List(issue.value.rolloutEntity));
+
+const failedTasks = computed(() => {
+ const tempList: Task[] = [];
+ props.taskSummaryReportMap.forEach((planCheckRun, taskId) => {
+ for (const result of planCheckRun.results) {
+ if (result.status === PlanCheckRun_Result_Status.ERROR) {
+ tempList.push(tasks.value.find((task) => task.name === taskId) as Task);
+ break;
+ }
+ }
+ });
+ return tempList;
+});
+
+const shouldShow = computed(() => failedTasks.value.length > 0);
+
+const failedMessageOfTask = (task: string) => {
+ const taskSummaryReport = props.taskSummaryReportMap.get(task);
+ if (!taskSummaryReport) return "";
+ const failedResults = taskSummaryReport.results.filter(
+ (result) => result.status === PlanCheckRun_Result_Status.ERROR
+ );
+ return failedResults.map((result) => result.content).join("\n");
+};
+
+const onClickTask = (task: Task) => {
+ events.emit("select-task", { task });
+};
+
+defineExpose({ shouldShow });
+</script>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/TaskCheckSummarySection.vue b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/TaskCheckSummarySection.vue
new file mode 100644
index 0000000000..00f45ac975
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/TaskCheckSummarySection.vue
@@ -0,0 +1,76 @@
+<template>
+ <div v-show="shouldShow" class="flex flex-col gap-y-1">
+ <div class="flex items-center gap-x-1 textlabel">
+ <span>{{ $t("common.summary") }}</span>
+ </div>
+ <div
+ class="w-full flex flex-row justify-start items-center gap-1 flex-wrap"
+ >
+ <AffectedRowsView
+ ref="affectedRowsViewRef"
+ :task-summary-report-map="taskSummaryReportMap"
+ />
+ <FailedTasksView
+ ref="failedTasksViewRef"
+ :task-summary-report-map="taskSummaryReportMap"
+ />
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { computed, ref } from "vue";
+import { useIssueContext } from "@/components/IssueV1";
+import {
+ PlanCheckRun_Type,
+ type PlanCheckRun,
+} from "@/types/proto/v1/plan_service";
+import {
+ flattenTaskV1List,
+ isDatabaseChangeRelatedIssue,
+ sheetNameOfTaskV1,
+} from "@/utils";
+import AffectedRowsView from "./AffectedRowsView.vue";
+import FailedTasksView from "./FailedTasksView.vue";
+
+const { issue, isCreating } = useIssueContext();
+
+const affectedRowsViewRef = ref<InstanceType<typeof AffectedRowsView>>();
+const failedTasksViewRef = ref<InstanceType<typeof FailedTasksView>>();
+
+const shouldShow = computed(() => {
+ if (isCreating.value) return false;
+ if (!isDatabaseChangeRelatedIssue(issue.value)) {
+ return false;
+ }
+ if (
+ !affectedRowsViewRef.value?.shouldShow &&
+ !failedTasksViewRef.value?.shouldShow
+ ) {
+ return false;
+ }
+ return true;
+});
+
+const tasks = computed(() => flattenTaskV1List(issue.value.rolloutEntity));
+
+const taskSummaryReportMap = computed(() => {
+ const { planCheckRunList } = issue.value;
+ const summaryReports = planCheckRunList.filter(
+ (report) =>
+ report.type === PlanCheckRun_Type.DATABASE_STATEMENT_SUMMARY_REPORT
+ );
+ const tempMap = new Map<string, PlanCheckRun>();
+ for (const task of tasks.value) {
+ const summaryReport = summaryReports.find(
+ (report) =>
+ report.target === task.target &&
+ report.sheet === sheetNameOfTaskV1(task)
+ );
+ if (summaryReport) {
+ tempMap.set(task.name, summaryReport);
+ }
+ }
+ return tempMap;
+});
+</script>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/index.ts b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/index.ts
new file mode 100644
index 0000000000..4c7f2738fb
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/index.ts
@@ -0,0 +1,3 @@
+import TaskCheckSummarySection from "./TaskCheckSummarySection.vue";
+
+export default TaskCheckSummarySection;
diff --git a/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue b/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue
index 988b5bde07..bdf7d5fd72 100644
--- a/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue
+++ b/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue
@@ -408,7 +408,10 @@ const categoryAndTitle = (
}
if (checkResult.sqlSummaryReport) {
if (typeof checkResult.sqlSummaryReport.affectedRows === "number") {
- return ["", t("task.check-type.affected-rows")];
+ return [
+ "",
+ `${t("task.check-type.affected-rows.self")} (${t("task.check-type.affected-rows.description")})`,
+ ];
}
return ["", checkResult.title];
}
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 4dce134abb..64316c9e3a 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -230,7 +230,9 @@
"finish": "Finish",
"title": "Title",
"text-wrap": "Text wrap",
- "catalog": "Catalog"
+ "catalog": "Catalog",
+ "summary": "Summary",
+ "errors": "Errors"
},
"error-page": {
"go-back-home": "Go back home"
@@ -258,7 +260,10 @@
"connection": "Connection",
"sql-review": "SQL review",
"ghost-sync": "gh-ost sync",
- "affected-rows": "Affected rows (estimation based on statistical information)",
+ "affected-rows": {
+ "self": "Affected rows",
+ "description": "Estimated by statistical information."
+ },
"summary-report": "Summary report"
},
"rollout-time": "Rollout time",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 7795197ef2..8b690c0c04 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -230,7 +230,9 @@
"finish": "Finalizar",
"title": "Título",
"text-wrap": "Ajuste de texto",
- "catalog": "Catálogo"
+ "catalog": "Catálogo",
+ "summary": "Resumen",
+ "errors": "Errores"
},
"error-page": {
"go-back-home": "Volver al inicio"
@@ -258,7 +260,10 @@
"connection": "Conexión",
"sql-review": "Revisión de SQL",
"ghost-sync": "Sincronización gh-ost",
- "affected-rows": "Filas afectadas (estimación basada en información estadística)",
+ "affected-rows": {
+ "self": "Filas afectadas",
+ "description": "Estimado por información estadística."
+ },
"summary-report": "Informe resumido"
},
"rollout-time": "Tiempo de implementación",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index a7ebe132ae..83f0c02dba 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -230,7 +230,9 @@
"finish": "仕上げる",
"title": "タイトル",
"text-wrap": "テキストの折り返し",
- "catalog": "カタログ"
+ "catalog": "カタログ",
+ "summary": "まとめ",
+ "errors": "エラー"
},
"error-page": {
"go-back-home": "ホームページに戻る"
@@ -258,7 +260,10 @@
"connection": "接続する",
"sql-review": "SQL監査",
"ghost-sync": "gh-ost同期",
- "affected-rows": "影響を受ける行数 (統計に基づいて推定)",
+ "affected-rows": {
+ "self": "影響を受ける行",
+ "description": "統計情報から推定。"
+ },
"summary-report": "概略報告"
},
"rollout-time": "公開時間を指定する",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index f9e1d88996..77c02e8e07 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -230,7 +230,9 @@
"finish": "完成",
"title": "标题",
"text-wrap": "文本折行",
- "catalog": "Catalog"
+ "catalog": "Catalog",
+ "summary": "总结",
+ "errors": "错误"
},
"error-page": {
"go-back-home": "回到主页"
@@ -258,7 +260,10 @@
"connection": "连接",
"sql-review": "SQL 审核",
"ghost-sync": "gh-ost 同步",
- "affected-rows": "影响行数(基于统计信息估算)",
+ "affected-rows": {
+ "self": "影响行数",
+ "description": "根据统计信息估算。"
+ },
"summary-report": "概要报告"
},
"rollout-time": "指定发布时间",
@@ -2745,4 +2750,4 @@
"last-visit": "上次访问",
"changelog-for-version": "{version} 的更新日志"
}
-}
+}
\ No newline at end of file