Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
perf(frontend): add pagination to ChecksView for better performance (#18410)
boojack95b965a08dc8
diff --git a/frontend/src/components/Plan/components/ChecksView/ChecksView.vue b/frontend/src/components/Plan/components/ChecksView/ChecksView.vueindex 6f9517a290..2daf943622 100644--- a/frontend/src/components/Plan/components/ChecksView/ChecksView.vue+++ b/frontend/src/components/Plan/components/ChecksView/ChecksView.vue@@ -54,17 +54,20 @@<CheckCircleIcon class="w-12 h-12 text-control-light opacity-50 mb-4" /><div class="text-lg text-control-light">{{- hasFilters ? "No results match your filters" : "No check results"+ hasFilters+ ? $t("plan.checks.no-results-match-filters")+ : $t("plan.checks.no-check-results")}}</div></div>- <div v-else class="divide-y">- <!-- Group by check run -->- <div- v-for="checkRun in filteredCheckRuns"- :key="checkRun.name"- class="px-2 py-4"- >+ <div v-else>+ <div class="divide-y">+ <!-- Group by check run -->+ <div+ v-for="checkRun in filteredCheckRuns"+ :key="checkRun.name"+ class="px-2 py-4"+ ><!-- Check Run Header --><div class="flex flex-wrap items-start justify-between gap-2 mb-2"><div class="flex items-center gap-3 shrink-0">@@ -98,7 +101,7 @@<!-- Results for this check run --><div class="flex flex-col gap-y-2 pl-8"><CheckResultItem- v-for="(result, idx) in getFilteredResults(checkRun)"+ v-for="(result, idx) in filteredResultsMap.get(checkRun.name)":key="idx":status="getCheckResultStatus(result.status)":title="result.title"@@ -119,6 +122,16 @@/></div></div>+ </div>+ <!-- Load more button -->+ <div v-if="hasMore" class="flex justify-center py-4">+ <button+ class="text-sm text-accent hover:underline"+ @click="loadMore"+ >+ {{ $t("common.load-more") }} ({{ remainingCount }})+ </button>+ </div></div></div></div>@@ -143,6 +156,7 @@ import { useI18n } from "vue-i18n";import { BBSpin } from "@/bbkit";import {type PlanCheckRun,+ type PlanCheckRun_Result,PlanCheckRun_ResultSchema,PlanCheckRun_Status,PlanCheckRun_Type,@@ -162,6 +176,14 @@ const { t } = useI18n();const selectedStatus = ref<Advice_Level | undefined>(props.defaultStatus);+// Pagination - load more+const PAGE_SIZE = 10;+const displayCount = ref(PAGE_SIZE);++const loadMore = () => {+ displayCount.value += PAGE_SIZE;+};+const hasFilters = computed(() => {return selectedStatus.value !== undefined;});@@ -204,22 +226,17 @@ const toggleSelectedStatus = (status: Advice_Level) => {} else {selectedStatus.value = status; // Select the new status}+ // Reset pagination when filter changes+ displayCount.value = PAGE_SIZE;};const getItemClass = (status: Advice_Level) => {- const classes: string[] = [];-- if (selectedStatus.value === status) {- classes.push("bg-gray-100 rounded-lg px-2 py-1");- } else {- // Add some padding to align with selected items- classes.push("px-2 py-1");- }-- return classes;+ return selectedStatus.value === status+ ? "bg-gray-100 rounded-lg px-2 py-1"+ : "px-2 py-1";};-const filteredCheckRuns = computed(() => {+const allFilteredCheckRuns = computed(() => {return props.planCheckRuns.filter((checkRun) => {// Filter by status - check if any result matches the selected statusif (selectedStatus.value !== undefined) {@@ -242,61 +259,79 @@ const filteredCheckRuns = computed(() => {});});-const getFilteredResults = (checkRun: PlanCheckRun) => {- let results = checkRun.results.filter((result) => {- return (- selectedStatus.value === undefined ||- result.status === selectedStatus.value- );- });+// Paginated check runs+const filteredCheckRuns = computed(() => {+ return allFilteredCheckRuns.value.slice(0, displayCount.value);+});++const hasMore = computed(() => {+ return allFilteredCheckRuns.value.length > displayCount.value;+});- // For failed check runs, add a synthetic error result if filtering for errors or no filter- if (- checkRun.status === PlanCheckRun_Status.FAILED &&- (selectedStatus.value === undefined ||- selectedStatus.value === Advice_Level.ERROR)- ) {- // Create a synthetic error result for the failed check run- const syntheticResult = create(PlanCheckRun_ResultSchema, {- status: Advice_Level.ERROR,- title: "Check Failed",- content: checkRun.error || "Plan check run failed",- code: 0,+const remainingCount = computed(() => {+ return allFilteredCheckRuns.value.length - displayCount.value;+});++// Memoized filtered results for each check run+const filteredResultsMap = computed(() => {+ const map = new Map<string, PlanCheckRun_Result[]>();+ for (const checkRun of filteredCheckRuns.value) {+ let results = checkRun.results.filter((result) => {+ return (+ selectedStatus.value === undefined ||+ result.status === selectedStatus.value+ );});- results = [syntheticResult, ...results];++ // For failed check runs, add a synthetic error result if filtering for errors or no filter+ if (+ checkRun.status === PlanCheckRun_Status.FAILED &&+ (selectedStatus.value === undefined ||+ selectedStatus.value === Advice_Level.ERROR)+ ) {+ const syntheticResult = create(PlanCheckRun_ResultSchema, {+ status: Advice_Level.ERROR,+ title: "Check Failed",+ content: checkRun.error || "Plan check run failed",+ code: 0,+ });+ results = [syntheticResult, ...results];+ }++ map.set(checkRun.name, results);}+ return map;+});- return results;+// Check type configuration lookup+const checkTypeConfig: Partial<+ Record<PlanCheckRun_Type, { icon: typeof FileCodeIcon; labelKey: string }>+> = {+ [PlanCheckRun_Type.DATABASE_STATEMENT_ADVISE]: {+ icon: SearchCodeIcon,+ labelKey: "task.check-type.sql-review.self",+ },+ [PlanCheckRun_Type.DATABASE_STATEMENT_SUMMARY_REPORT]: {+ icon: FileCodeIcon,+ labelKey: "task.check-type.summary-report",+ },+ [PlanCheckRun_Type.DATABASE_CONNECT]: {+ icon: DatabaseIcon,+ labelKey: "task.check-type.connection",+ },+ [PlanCheckRun_Type.DATABASE_GHOST_SYNC]: {+ icon: ShieldIcon,+ labelKey: "task.check-type.ghost-sync",+ },};const getCheckTypeIcon = (type: PlanCheckRun_Type) => {- switch (type) {- case PlanCheckRun_Type.DATABASE_STATEMENT_ADVISE:- return SearchCodeIcon;- case PlanCheckRun_Type.DATABASE_STATEMENT_SUMMARY_REPORT:- return FileCodeIcon;- case PlanCheckRun_Type.DATABASE_CONNECT:- return DatabaseIcon;- case PlanCheckRun_Type.DATABASE_GHOST_SYNC:- return ShieldIcon;- default:- return FileCodeIcon;- }+ return checkTypeConfig[type]?.icon ?? FileCodeIcon;};const getCheckTypeLabel = (type: PlanCheckRun_Type) => {- switch (type) {- case PlanCheckRun_Type.DATABASE_STATEMENT_ADVISE:- return t("task.check-type.sql-review.self");- case PlanCheckRun_Type.DATABASE_STATEMENT_SUMMARY_REPORT:- return t("task.check-type.summary-report");- case PlanCheckRun_Type.DATABASE_CONNECT:- return t("task.check-type.connection");- case PlanCheckRun_Type.DATABASE_GHOST_SYNC:- return t("task.check-type.ghost-sync");- default:- return type.toString();- }+ const key = checkTypeConfig[type]?.labelKey;+ return key ? t(key) : type.toString();};const getCheckTypeDescription = (type: PlanCheckRun_Type) => {@@ -315,18 +350,17 @@ const formatTime = (timestamp: Timestamp | undefined): string => {);};+const adviceLevelToStatus: Partial<+ Record<Advice_Level, "SUCCESS" | "WARNING" | "ERROR">+> = {+ [Advice_Level.ERROR]: "ERROR",+ [Advice_Level.WARNING]: "WARNING",+ [Advice_Level.SUCCESS]: "SUCCESS",+};+const getCheckResultStatus = (status: Advice_Level): "SUCCESS" | "WARNING" | "ERROR" => {- switch (status) {- case Advice_Level.ERROR:- return "ERROR";- case Advice_Level.WARNING:- return "WARNING";- case Advice_Level.SUCCESS:- return "SUCCESS";- default:- return "SUCCESS";- }+ return adviceLevelToStatus[status] ?? "SUCCESS";};</script>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex f27453a981..0bf56b2975 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1135,6 +1135,11 @@"rollout": "Rollout","statement-empty": "Statement is empty"},+ "checks": {+ "self": "Checks",+ "no-results-match-filters": "No results match your filters",+ "no-check-results": "No check results"+ },"spec": {"change": "Change","type": {@@ -1187,9 +1192,6 @@"some-databases-have-issues": "{count} database has issues | {count} databases have issues","configuration-has-issues": "Configuration has {count} issue | Configuration has {count} issues"},- "checks": {- "self": "Checks"- },"refresh-indicator": {"last-refresh": "Last refresh: {time}"},diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex f58250b978..ff99086f2e 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1135,6 +1135,11 @@"rollout": "Despliegue","statement-empty": "La declaración está vacía"},+ "checks": {+ "self": "Cheques",+ "no-results-match-filters": "No hay resultados que coincidan con sus filtros",+ "no-check-results": "Sin resultados de verificación"+ },"spec": {"change": "Cambiar","type": {@@ -1187,9 +1192,6 @@"some-databases-have-issues": "{count} la base de datos tiene problemas | {count} las bases de datos tienen problemas","configuration-has-issues": "La configuración tiene {count} problemas | La configuración tiene {count} problemas"},- "checks": {- "self": "Cheques"- },"refresh-indicator": {"last-refresh": "Última actualización: {time}"},@@ -1626,7 +1628,6 @@"establish-database-baseline": "Establecer línea base de \"{name}\"","export": "Exportar historial de cambios","need-to-select-first": "Necesita seleccionar primero el historial de cambios",-"rollback-tip": "Seleccione un historial de DDL específico para revertir."},"database": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 19579e3d17..7215c97429 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1135,6 +1135,11 @@"rollout": "ロールアウトする","statement-empty": "ステートメントが空です"},+ "checks": {+ "self": "小切手",+ "no-results-match-filters": "フィルターに一致する結果がありません",+ "no-check-results": "チェック結果がありません"+ },"spec": {"change": "変化","type": {@@ -1187,9 +1192,6 @@"some-databases-have-issues": "{count} データベースに問題があります | {count} データベースに問題があります","configuration-has-issues": "構成に {count} 個の問題があります | 構成に {count} 個の問題があります"},- "checks": {- "self": "小切手"- },"refresh-indicator": {"last-refresh": "最終更新: {time}"},@@ -1626,7 +1628,6 @@"establish-database-baseline": "ベースライン「{name}」を作成します","export": "変更履歴のエクスポート","need-to-select-first": "最初に変更履歴を選択する必要があります",-"rollback-tip": "ロールバックする特定の DDL 履歴を選択します。"},"database": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 3840418e99..4793612856 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1135,6 +1135,11 @@"rollout": "Triển khai","statement-empty": "Câu lệnh trống rỗng"},+ "checks": {+ "self": "Kiểm tra",+ "no-results-match-filters": "Không có kết quả nào phù hợp với bộ lọc của bạn",+ "no-check-results": "Không có kết quả kiểm tra"+ },"spec": {"change": "Thay đổi","type": {@@ -1187,9 +1192,6 @@"some-databases-have-issues": "{count} cơ sở dữ liệu có vấn đề | {count} cơ sở dữ liệu có vấn đề","configuration-has-issues": "Cấu hình có vấn đề {count} | Cấu hình có vấn đề {count}"},- "checks": {- "self": "Kiểm tra"- },"refresh-indicator": {"last-refresh": "Làm mới lần cuối: {time}"},@@ -1626,7 +1628,6 @@"establish-database-baseline": "Thiết lập đường cơ sở \"{name}\"","export": "Xuất Nhật ký thay đổi","need-to-select-first": "Cần chọn nhật ký thay đổi trước",-"rollback-tip": "Chọn một nhật ký thay đổi DDL cụ thể để hoàn tác."},"database": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 01e1427a17..8f8f923921 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1135,6 +1135,11 @@"rollout": "发布任务","statement-empty": "变更语句为空"},+ "checks": {+ "self": "检查",+ "no-results-match-filters": "没有匹配筛选条件的结果",+ "no-check-results": "没有检查结果"+ },"spec": {"change": "变更项","type": {@@ -1187,9 +1192,6 @@"some-databases-have-issues": "{count} 个数据库有问题 | {count} 个数据库有问题","configuration-has-issues": "配置存在 {count} 个问题 | 配置存在 {count} 个问题"},- "checks": {- "self": "检查"- },"refresh-indicator": {"last-refresh": "上次刷新:{time}"},@@ -1626,7 +1628,6 @@"establish-database-baseline": "建立「{name}」基线","export": "导出变更历史","need-to-select-first": "需要先选择变更历史",-"rollback-tip": "选择要回滚到的某个 DDL 历史记录。"},"database": {