@@ -163,7 +163,7 @@ projectRouter.route('/').get(
163163 }
164164 }
165165 // Get the number of projects to be matched with the current query
166- let projectCount = await database . projects . countDocuments ( finder ) ;
166+ let filteredCount = await database . projects . countDocuments ( finder ) ;
167167 // Finally, perform the mongo query
168168 // WARNING: If the query is wrong it will not make the code fail until the cursor in consumed
169169 // e.g. cursor.toArray()
@@ -175,14 +175,14 @@ projectRouter.route('/').get(
175175 . sort ( sortOptions ) ;
176176 // If there are no results, we try it with the mongo internal ids
177177 // This only works with the full object id, not partial ids
178- if ( projectCount === 0 && / [ a - z 0 - 9 ] { 24 } / . test ( search ) ) {
178+ if ( filteredCount === 0 && / [ a - z 0 - 9 ] { 24 } / . test ( search ) ) {
179179 const id = ObjectId ( search . match ( / [ a - z 0 - 9 ] { 24 } / ) [ 0 ] ) ;
180180 const newFinder = { _id : id } ;
181- projectCount = await database . projects . countDocuments ( newFinder ) ;
181+ filteredCount = await database . projects . countDocuments ( newFinder ) ;
182182 cursor = await database . projects . find ( newFinder ) ;
183183 }
184184 // If we still having no results then return here
185- if ( projectCount === 0 ) return { filteredCount : 0 , totalMdsCount : 0 , projects : [ ] } ;
185+ if ( filteredCount === 0 ) return { filteredCount : 0 , totalMdsCount : 0 , projects : [ ] } ;
186186
187187 // Get the limit of projects to be returned according to the query
188188 // If the query has no limit it is set to 10 by default
@@ -216,7 +216,7 @@ projectRouter.route('/').get(
216216 const totalMdsCount = shouldCountMds ? await countTotalMds ( ) : null ;
217217
218218 // If the limit is set to 0 then return here
219- if ( limit === 0 ) return { filteredCount : projectCount , totalMdsCount, projects : [ ] } ;
219+ if ( limit === 0 ) return { filteredCount, totalMdsCount, projects : [ ] } ;
220220
221221 // Finally consume the cursor
222222 const projects = await cursor
@@ -236,7 +236,7 @@ projectRouter.route('/').get(
236236 . map ( project => projectMapping ( project ) )
237237 // Changes the type from Cursor into Array, then saving data in memory
238238 . toArray ( ) ;
239- return { projectCount , totalMdsCount, projects } ;
239+ return { filteredCount , totalMdsCount, projects } ;
240240 }
241241 } ) ,
242242) ;
0 commit comments