import { TRANSFORM_STATE } from '../../../common/constants' ; import { TransformListRow } from './transform_list' ; import { PutTransformsLatestRequestSchema , PutTransformsPivotRequestSchema , } from '../../../common/api_schemas/transforms' ; type TransformItem = Omit < TransformListRow , 'config' > & { config : TransformListRow [ 'config' ] | PutTransformsLatestRequestSchema | PutTransformsPivotRequestSchema ; } ; export function getTransformProgress ( item ) { if ( isCompletedBatchTransform ( item ) ) { return 100 ; } const progress = item ?. stats ?. checkpointing ?. next ?. checkpoint_progress ?. percent_complete ; return progress !== undefined ? Math . round ( progress ) : undefined ; } export function isCompletedBatchTransform ( item ) { return ( item . stats . checkpointing . last . checkpoint === 1 && item . config . sync === undefined && item . stats . state === TRANSFORM_STATE . STOPPED ) ; }