MCPcopy Create free account
hub / github.com/RealDevSquad/website-backend / fetchUsers

Function fetchUsers

models/users.js:347–380  ·  view source on GitHub ↗
(usernames = [])

Source from the content-addressed store, hash-verified

345 };
346 } catch (err) {
347 logger.error("Error retrieving user data", err);
348 throw err;
349 }
350};
351
352const fetchUsers = async (usernames = []) => {
353 try {
354 const dbQuery = userModel;
355 const users = [];
356
357 const groups = [];
358 for (let i = 0; i < usernames.length; i += BATCH_SIZE_IN_CLAUSE) {
359 groups.push(usernames.slice(i, i + BATCH_SIZE_IN_CLAUSE));
360 }
361
362 // For each group, write a separate query
363 const promises = groups.map((group) => {
364 return dbQuery.where("github_id", "in", group).get();
365 });
366
367 const snapshots = await Promise.all(promises);
368
369 snapshots.forEach((snapshot) => {
370 snapshot.forEach((doc) => {
371 users.push({
372 ...doc.data(),
373 id: doc.id,
374 });
375 });
376 });
377
378 return {
379 users,
380 };
381 } catch (err) {
382 logger.error("Error retrieving user data", err);
383 throw err;

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected