-
Notifications
You must be signed in to change notification settings - Fork 17
fix: progress is not shown for export #3092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+309
−29
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cff5216
fix: progress is not shown for export
astandrik 53e6f39
fix: review fixes
astandrik d7b47e5
fix: review fixes
astandrik 848ffd3
fix: nanotuting
astandrik 6f7a59b
fix: use constants
astandrik f02a6de
fix: i18n
astandrik 6c05177
fix: nanofix
astandrik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import {parseProtobufTimestampToMs} from '../../utils/timeParsers'; | |
|
|
||
| import {COLUMNS_NAMES, COLUMNS_TITLES} from './constants'; | ||
| import i18n from './i18n'; | ||
| import {getOperationProgress} from './utils'; | ||
|
|
||
| import './Operations.scss'; | ||
|
|
||
|
|
@@ -28,13 +29,14 @@ export function getColumns({ | |
| kind: OperationKind; | ||
| }): DataTableColumn<TOperation>[] { | ||
| const isBuildIndex = kind === 'buildindex'; | ||
| const isImportOrExport = ['import/s3', 'export/s3', 'export/yt'].includes(kind); | ||
|
|
||
| // Helper function to get description tooltip content | ||
| const getDescriptionTooltip = (operation: TOperation): string => { | ||
| if (!operation.metadata?.description) { | ||
| // Helper function to get description tooltip content (buildindex-only) | ||
| const getDescriptionTooltip = (metadata?: IndexBuildMetadata): string => { | ||
| if (!metadata?.description) { | ||
| return ''; | ||
| } | ||
| return JSON.stringify(operation.metadata.description, null, 2); | ||
| return JSON.stringify(metadata.description, null, 2); | ||
| }; | ||
|
|
||
| const columns: DataTableColumn<TOperation>[] = [ | ||
|
|
@@ -47,7 +49,10 @@ export function getColumns({ | |
| return EMPTY_DATA_PLACEHOLDER; | ||
| } | ||
|
|
||
| const tooltipContent = isBuildIndex ? getDescriptionTooltip(row) || row.id : row.id; | ||
| const tooltipContent = isBuildIndex | ||
| ? getDescriptionTooltip(row.metadata as IndexBuildMetadata | undefined) || | ||
|
||
| row.id | ||
| : row.id; | ||
|
|
||
| return ( | ||
| <CellWithPopover placement={['top', 'bottom']} content={tooltipContent}> | ||
|
|
@@ -72,34 +77,38 @@ export function getColumns({ | |
| }, | ||
| ]; | ||
|
|
||
| // Add buildindex-specific columns | ||
| // Add buildindex-specific state column | ||
| if (isBuildIndex) { | ||
| columns.push( | ||
| { | ||
| name: COLUMNS_NAMES.STATE, | ||
| header: COLUMNS_TITLES[COLUMNS_NAMES.STATE], | ||
| render: ({row}) => { | ||
| const metadata = row.metadata as IndexBuildMetadata | undefined; | ||
| if (!metadata?.state) { | ||
| return EMPTY_DATA_PLACEHOLDER; | ||
| } | ||
| return metadata.state; | ||
| }, | ||
| columns.push({ | ||
| name: COLUMNS_NAMES.STATE, | ||
| header: COLUMNS_TITLES[COLUMNS_NAMES.STATE], | ||
| render: ({row}) => { | ||
| const metadata = row.metadata as IndexBuildMetadata | undefined; | ||
| if (!metadata?.state) { | ||
| return EMPTY_DATA_PLACEHOLDER; | ||
| } | ||
| return metadata.state; | ||
| }, | ||
| { | ||
| name: COLUMNS_NAMES.PROGRESS, | ||
| header: COLUMNS_TITLES[COLUMNS_NAMES.PROGRESS], | ||
| render: ({row}) => { | ||
| const metadata = row.metadata as IndexBuildMetadata | undefined; | ||
| if (metadata?.progress === undefined) { | ||
| return EMPTY_DATA_PLACEHOLDER; | ||
| } | ||
| return `${Math.round(metadata.progress)}%`; | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| // Add progress column for operations that have progress data | ||
| if (isBuildIndex || isImportOrExport) { | ||
| columns.push({ | ||
| name: COLUMNS_NAMES.PROGRESS, | ||
| header: COLUMNS_TITLES[COLUMNS_NAMES.PROGRESS], | ||
| render: ({row}) => { | ||
| const progress = getOperationProgress(row, i18n); | ||
| if (progress === null) { | ||
| return EMPTY_DATA_PLACEHOLDER; | ||
| } | ||
| return progress; | ||
| }, | ||
| ); | ||
| } else { | ||
| // Add standard columns for non-buildindex operations | ||
| }); | ||
| } | ||
|
|
||
| // Add standard columns for non-buildindex operations | ||
| if (!isBuildIndex) { | ||
| columns.push( | ||
| { | ||
| name: COLUMNS_NAMES.CREATED_BY, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| import type { | ||
| ExportToS3Metadata, | ||
| ExportToYtMetadata, | ||
| ImportFromS3Metadata, | ||
| TOperation, | ||
| } from '../../types/api/operations'; | ||
|
|
||
| // i18n keys for import/export progress enum values | ||
| // value_progress_unspecified, value_progress_preparing, etc. | ||
| export type OperationProgressKey = | ||
| | 'value_progress_unspecified' | ||
| | 'value_progress_preparing' | ||
| | 'value_progress_transfer_data' | ||
| | 'value_progress_build_indexes' | ||
| | 'value_progress_done' | ||
| | 'value_progress_cancellation' | ||
| | 'value_progress_cancelled' | ||
| | 'value_progress_create_changefeeds'; | ||
|
|
||
| /** | ||
| * Calculate progress percentage from Import/Export metadata | ||
| * | ||
| * Calculates overall progress based on items_progress array: | ||
| * - Sums all parts_total and parts_completed across all items | ||
| * - Returns percentage rounded to nearest integer | ||
| * | ||
| * @param metadata - Import/Export operation metadata | ||
| * @returns Progress percentage (0-100) or null if cannot be calculated | ||
| */ | ||
| export function calculateImportExportProgress( | ||
| metadata: ImportFromS3Metadata | ExportToS3Metadata | ExportToYtMetadata | undefined, | ||
| ): number | null { | ||
| if (!metadata?.items_progress || metadata.items_progress.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| let totalParts = 0; | ||
| let completedParts = 0; | ||
|
|
||
| for (const item of metadata.items_progress) { | ||
| if (item.parts_total !== undefined && item.parts_total > 0) { | ||
| totalParts += item.parts_total; | ||
| completedParts += item.parts_completed || 0; | ||
| } | ||
| } | ||
|
|
||
| if (totalParts === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| return Math.round((completedParts / totalParts) * 100); | ||
| } | ||
|
|
||
| /** | ||
| * Get progress display value for an operation | ||
| * | ||
| * Handles different progress formats: | ||
| * - BuildIndex: numeric progress (0-100) -> "75%" | ||
| * - Import/Export: calculated from items_progress -> "45%" or enum value -> "Done" | ||
| * | ||
| * @param operation - Operation to get progress for | ||
| * @param translateProgress - Function to translate progress enum values (i18n) | ||
| * @returns Formatted progress string or null if no progress available | ||
| */ | ||
| export function getOperationProgress( | ||
| operation: TOperation, | ||
| translateProgress: (key: OperationProgressKey) => string, | ||
| ): string | null { | ||
| const metadata = operation.metadata; | ||
|
|
||
| if (!metadata) { | ||
| return null; | ||
| } | ||
|
|
||
| if (metadata['@type'] === 'type.googleapis.com/Ydb.Table.IndexBuildMetadata') { | ||
| const buildIndexMetadata = metadata; | ||
| if (typeof buildIndexMetadata.progress === 'number') { | ||
| return `${Math.round(buildIndexMetadata.progress)}%`; | ||
| } | ||
| } | ||
|
|
||
| // Import/Export: calculate from items_progress or show enum value | ||
| if ( | ||
| metadata['@type'] === 'type.googleapis.com/Ydb.Import.ImportFromS3Metadata' || | ||
| metadata['@type'] === 'type.googleapis.com/Ydb.Export.ExportToS3Metadata' || | ||
| metadata['@type'] === 'type.googleapis.com/Ydb.Export.ExportToYtMetadata' | ||
| ) { | ||
| const importExportMetadata = metadata; | ||
|
|
||
| // Try to calculate percentage from items_progress | ||
| const calculatedProgress = calculateImportExportProgress(importExportMetadata); | ||
| if (calculatedProgress !== null) { | ||
| return `${calculatedProgress}%`; | ||
| } | ||
|
|
||
| // Fallback to enum progress value | ||
| if (importExportMetadata.progress) { | ||
| const progressValue = | ||
| typeof importExportMetadata.progress === 'string' | ||
| ? importExportMetadata.progress | ||
| : String(importExportMetadata.progress); | ||
|
|
||
| const normalized = progressValue.toLowerCase(); // progress_done | ||
| const i18nKey = `value_${normalized}` as OperationProgressKey; | ||
astandrik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| try { | ||
| const translated = translateProgress(i18nKey); | ||
| if (translated && translated !== i18nKey) { | ||
| return translated; | ||
| } | ||
| } catch {} | ||
|
|
||
| return progressValue; | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe take constant out of function?