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

Function getSuggestedUsers

models/users.js:224–248  ·  view source on GitHub ↗
(skill)

Source from the content-addressed store, hash-verified

222/**
223 * Fetches users with the given skill
224 *
225 * @param skill { string }: Skill
226 * @return @return {Promise<users>}
227 */
228
229const getSuggestedUsers = async (skill) => {
230 try {
231 const data = await itemModel.where("itemType", "==", "USER").where("tagId", "==", skill).get();
232 let users = [];
233
234 const dataSet = new Set();
235
236 if (!data.empty) {
237 data.forEach((doc) => {
238 const docUserId = doc.data().itemId;
239 if (!dataSet.has(docUserId)) {
240 dataSet.add(docUserId);
241 }
242 });
243 const usersId = Array.from(dataSet);
244 const usersArray = usersId.map((userId) => fetchUser({ userId }));
245 users = await Promise.all(usersArray);
246 }
247
248 return { users };
249 } catch (err) {
250 logger.error("Error in getting suggested user", err);
251 throw err;

Callers

nothing calls this directly

Calls 2

fetchUserFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected