File tree Expand file tree Collapse file tree 1 file changed +23
-10
lines changed Expand file tree Collapse file tree 1 file changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -181,21 +181,34 @@ const fetchPaginatedUsers = async (query) => {
181
181
const fetchFilteredUsers = async ( usernames = [ ] ) => {
182
182
try {
183
183
const dbQuery = userModel ;
184
+ const filterdUsersWithDetails = [ ] ;
184
185
185
- const snapshot = await dbQuery . where ( "github_id" , "in" , usernames ) . get ( ) ;
186
+ const groups = [ ] ;
187
+ const batchSize = 30 ; // since only 30 comparisons are allowed with the 'in' clause
188
+ for ( let i = 0 ; i < usernames . length ; i += batchSize ) {
189
+ groups . push ( usernames . slice ( i , i + batchSize ) ) ;
190
+ }
186
191
187
- const filterdUsersWithDetails = [ ] ;
192
+ // For each group, write a separate query
193
+ const promises = groups . map ( ( group ) => {
194
+ return dbQuery . where ( "github_id" , "in" , group ) . get ( ) ;
195
+ } ) ;
188
196
189
- snapshot . forEach ( ( doc ) => {
190
- filterdUsersWithDetails . push ( {
191
- id : doc . id ,
192
- ...doc . data ( ) ,
193
- phone : undefined ,
194
- email : undefined ,
195
- tokens : undefined ,
196
- chaincode : undefined ,
197
+ const snapshots = await Promise . all ( promises ) ;
198
+
199
+ snapshots . forEach ( ( snapshot ) => {
200
+ snapshot . forEach ( ( doc ) => {
201
+ filterdUsersWithDetails . push ( {
202
+ id : doc . id ,
203
+ ...doc . data ( ) ,
204
+ phone : undefined ,
205
+ email : undefined ,
206
+ tokens : undefined ,
207
+ chaincode : undefined ,
208
+ } ) ;
197
209
} ) ;
198
210
} ) ;
211
+
199
212
return {
200
213
filterdUsersWithDetails,
201
214
} ;
You can’t perform that action at this time.
0 commit comments