File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
packages/data-service/src Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -2137,7 +2137,7 @@ class DataServiceImpl extends WithLogContext implements DataService {
21372137 private async _indexProgress ( ns : string ) : Promise < Record < string , number > > {
21382138 type IndexProgressResult = {
21392139 _id : string ;
2140- progress : { done : number ; total : number } ;
2140+ progress : number ;
21412141 } ;
21422142
21432143 const currentOps : IndexProgressResult [ ] = await this . _database (
@@ -2157,7 +2157,15 @@ class DataServiceImpl extends WithLogContext implements DataService {
21572157 {
21582158 $group : {
21592159 _id : '$command.indexes.name' ,
2160- progress : { $first : '$progress' } ,
2160+ progress : {
2161+ $first : {
2162+ $cond : {
2163+ if : { $gt : [ '$progress.total' , 0 ] } ,
2164+ then : { $divide : [ '$progress.done' , '$progress.total' ] } ,
2165+ else : 0 ,
2166+ } ,
2167+ } ,
2168+ } ,
21612169 } ,
21622170 } , // group on index name
21632171 ] )
@@ -2166,7 +2174,7 @@ class DataServiceImpl extends WithLogContext implements DataService {
21662174
21672175 const indexToProgress = Object . create ( null ) ;
21682176 for ( const { _id, progress } of currentOps ) {
2169- indexToProgress [ _id ] = progress . done / progress . total ;
2177+ indexToProgress [ _id ] = progress ;
21702178 }
21712179
21722180 return indexToProgress ;
You can’t perform that action at this time.
0 commit comments