Skip to content

Commit

Permalink
async filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Shiel authored and Aaron Shiel committed Nov 6, 2024
1 parent 15be481 commit aa39a5d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions node/src/gql/query/answers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { User } from '../../models/User';
import { canViewMentor } from '../../utils/check-permissions';
import AnswerType from '../types/answer';
import findAll from './find-all';
import { getUsersManagedOrgs } from '../mutation/me/helpers';
import { asyncFilter, getUsersManagedOrgs } from '../mutation/me/helpers';

export const answers = findAll({
nodeType: AnswerType,
Expand All @@ -26,7 +26,8 @@ export const answers = findAll({
);
const mentors = await MentorModel.find({ _id: { $in: mentorIds } });
const userOrgs = await getUsersManagedOrgs(context.user);
const newAnswerResults: Answer[] = paginationResults.results.filter(
const newAnswerResults: Answer[] = await asyncFilter(
paginationResults.results,
async (a: Answer) => {
const mentor = mentors.find((m) => `${m._id}` === `${a.mentor}`);
if (!mentor) {
Expand Down

0 comments on commit aa39a5d

Please sign in to comment.