Skip to content

Commit 78fcf24

Browse files
committed
Add ProjectFilters.members & membership
1 parent 4578b19 commit 78fcf24

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/components/project/dto/list-projects.dto.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from '~/common';
1717
import { LocationFilters } from '../../location/dto';
1818
import { PartnershipFilters } from '../../partnership/dto';
19+
import { ProjectMemberFilters } from '../project-member/dto';
1920
import { ProjectStatus } from './project-status.enum';
2021
import { ProjectStep } from './project-step.enum';
2122
import { ProjectType } from './project-type.enum';
@@ -96,6 +97,17 @@ export abstract class ProjectFilters {
9697
})
9798
readonly isMember?: boolean;
9899

100+
@FilterField(() => ProjectMemberFilters, {
101+
description:
102+
"Only projects with the requesting user's membership that matches these filters",
103+
})
104+
readonly membership?: ProjectMemberFilters & {};
105+
106+
@FilterField(() => ProjectMemberFilters, {
107+
description: 'Only projects with _any_ members matching these filters',
108+
})
109+
readonly members?: ProjectMemberFilters & {};
110+
99111
@OptionalField({
100112
description: 'Filter for projects with two or more engagements.',
101113
})

src/components/project/project-filters.query.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { locationFilters } from '../location/location.repository';
1717
import { partnershipFilters } from '../partnership/partnership.repository';
1818
import { ProjectFilters } from './dto';
19+
import { projectMemberFilters } from './project-member/project-member.repository';
1920
import { ProjectNameIndex } from './project.repository';
2021

2122
export const projectFilters = filter.define(() => ProjectFilters, {
@@ -56,6 +57,22 @@ export const projectFilters = filter.define(() => ProjectFilters, {
5657
relation('in', '', 'member'),
5758
node('node'),
5859
]),
60+
membership: filter.sub(() => projectMemberFilters)((sub) =>
61+
sub.match([
62+
currentUser,
63+
relation('in', '', 'user'),
64+
node('node', 'ProjectMember'),
65+
relation('in', '', 'member'),
66+
node('outer'),
67+
]),
68+
),
69+
members: filter.sub(() => projectMemberFilters)((sub) =>
70+
sub.match([
71+
node('node', 'ProjectMember'),
72+
relation('in', '', 'member'),
73+
node('outer'),
74+
]),
75+
),
5976
userId: ({ value }) => ({
6077
userId: [
6178
// TODO We can leak if the project includes this person, if the

0 commit comments

Comments
 (0)