From 900f99797fbc196fc6234e9ec7017670d1945586 Mon Sep 17 00:00:00 2001 From: Abeautifulsnow Date: Thu, 24 Sep 2026 19:33:19 +0800 Subject: [PATCH] feat(grid): show query elapsed time in adaptive units --- .../src/components/editor/QueryHistory.vue | 5 +- apps/desktop/src/components/grid/DataGrid.vue | 3 +- .../components/grid/QueryTimingDetails.vue | 5 +- .../grid/__tests__/QueryTimingDetails.spec.ts | 2 +- .../src/components/hbase/HBaseBrowser.vue | 3 +- .../meilisearch/MeilisearchDocumentsPage.vue | 3 +- .../src/composables/useExportTracker.ts | 19 ++----- .../gridDurationPlaceholderParity.spec.ts | 50 +++++++++++++++++++ apps/desktop/src/i18n/locales/az.ts | 2 +- apps/desktop/src/i18n/locales/en.ts | 10 ++-- apps/desktop/src/i18n/locales/es.ts | 10 ++-- apps/desktop/src/i18n/locales/it.ts | 10 ++-- apps/desktop/src/i18n/locales/ja.ts | 10 ++-- apps/desktop/src/i18n/locales/ko.ts | 10 ++-- apps/desktop/src/i18n/locales/pt-BR.ts | 10 ++-- apps/desktop/src/i18n/locales/ru.ts | 10 ++-- apps/desktop/src/i18n/locales/tr.ts | 2 +- apps/desktop/src/i18n/locales/zh-CN.ts | 10 ++-- apps/desktop/src/i18n/locales/zh-TW.ts | 10 ++-- .../src/lib/format/__tests__/duration.spec.ts | 44 ++++++++++++++++ apps/desktop/src/lib/format/duration.ts | 36 +++++++++++++ 21 files changed, 195 insertions(+), 69 deletions(-) create mode 100644 apps/desktop/src/i18n/__tests__/gridDurationPlaceholderParity.spec.ts create mode 100644 apps/desktop/src/lib/format/__tests__/duration.spec.ts create mode 100644 apps/desktop/src/lib/format/duration.ts diff --git a/apps/desktop/src/components/editor/QueryHistory.vue b/apps/desktop/src/components/editor/QueryHistory.vue index 9894979fee..93f1a79e37 100644 --- a/apps/desktop/src/components/editor/QueryHistory.vue +++ b/apps/desktop/src/components/editor/QueryHistory.vue @@ -17,6 +17,7 @@ import { hasHistoryDateRange, historyDateRangeIsValid, type HistoryDateRange } f import { HISTORY_ROW_HEIGHT, HISTORY_SCROLL_BUFFER, shouldVirtualizeHistory } from "@/lib/history/historyVirtualList"; import { historyConnectionHasSelectedDatabase } from "@/lib/history/historySearch"; import { historyEntrySource } from "@/lib/history/historyEntrySource"; +import { formatQueryDuration } from "@/lib/format/duration"; import type { HistoryConnectionFilter, HistoryDatabaseFilter, HistoryEntry, HistorySearchRequest } from "@/lib/backend/api"; import { copyToClipboard } from "@/lib/common/clipboard"; import { executeWithProductionSqlGuard } from "@/lib/database/productionExecutionGuard"; @@ -356,7 +357,7 @@ function detailsRows(entry: HistoryEntry) { [t("history.detail.database"), entry.database || "-"], [t("history.detail.target"), entry.target || "-"], [t("history.detail.time"), formatFullTime(entry.executed_at)], - [t("history.detail.duration"), `${entry.execution_time_ms}ms`], + [t("history.detail.duration"), formatQueryDuration(entry.execution_time_ms)], [t("history.detail.affectedRows"), entry.affected_rows ?? "-"], [t("history.detail.rollback"), canRollbackHistoryEntry(entry) ? t("history.rollbackAvailable") : t("history.rollbackUnavailable")], [t("history.detail.status"), entry.success ? t("history.success") : t("history.failed")], @@ -707,7 +708,7 @@ onBeforeUnmount(() => { - {{ entry.success ? `${entry.execution_time_ms}ms` : t("history.failed") }} + {{ entry.success ? formatQueryDuration(entry.execution_time_ms) : t("history.failed") }} diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue index 79adae8f95..3255805a1e 100644 --- a/apps/desktop/src/components/grid/DataGrid.vue +++ b/apps/desktop/src/components/grid/DataGrid.vue @@ -337,6 +337,7 @@ import { useSettingsStore } from "@/stores/settingsStore"; import { databaseSortSupportedForDatabase, simpleDataGridOrderByMatchesSort, simpleDataGridOrderByReferencesMissingColumn, type DataGridSortDirection, type DataGridSortMode } from "@/lib/dataGrid/dataGridSort"; import { resolveGridFocusRestoreTarget, shouldRestoreDataGridFocusAfterEditCommit } from "@/lib/dataGrid/dataGridFocusRestore"; import { buildOrderedGridRows, type GridInsertRowPosition, type GridNewRowPlacement } from "@/lib/dataGrid/gridNewRowPlacement"; +import { formatQueryDuration } from "@/lib/format/duration"; import { DATA_GRID_CONDITION_TOOLBAR_MIN_WIDTH, DATA_GRID_TOOLBAR_ACTION_COLLAPSE_ORDER, @@ -13989,7 +13990,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val (truncated) {{ t("grid.rowsAffected", { count: result.affected_rows }) }} - {{ result.execution_time_ms }}ms + {{ formatQueryDuration(result.execution_time_ms) }}