Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/irl filters #2029

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions apps/web-api/src/members/members.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,21 @@ export class MemberController {
const queryParams = request.query;
const builder = new PrismaQueryBuilder(queryableFields);
const builtQuery = builder.build(queryParams);
const { name__icontains } = queryParams;
const { name__icontains, isHost, isSpeaker } = queryParams;
if (name__icontains) {
delete builtQuery.where?.name;
}
if (isHost || isSpeaker) { //Remove isHost and isSpeaker from the default query since it is to be added in eventGuest.
delete builtQuery.where?.isHost;
delete builtQuery.where?.isSpeaker;
}
builtQuery.where = {
AND: [
builtQuery.where,
this.membersService.buildNameFilters(queryParams),
this.membersService.buildRoleFilters(queryParams),
this.membersService.buildRecentMembersFilter(queryParams)
this.membersService.buildRecentMembersFilter(queryParams),
this.membersService.buildParticipationTypeFilter(queryParams)
],
};
return await this.membersService.findAll(builtQuery);
Expand Down Expand Up @@ -110,16 +115,21 @@ export class MemberController {
const queryParams = request.query;
const builder = new PrismaQueryBuilder(queryableFields);
const builtQuery = builder.build(queryParams);
const { name__icontains } = queryParams;
const { name__icontains, isHost, isSpeaker } = queryParams;
if (name__icontains) {
delete builtQuery.where?.name;
}
if (isHost || isSpeaker) { //Remove isHost and isSpeaker from the default query since it is to be added in eventGuest.
delete builtQuery.where?.isHost;
delete builtQuery.where?.isSpeaker;
}
builtQuery.where = {
AND: [
builtQuery.where,
this.membersService.buildNameFilters(queryParams),
this.membersService.buildRoleFilters(queryParams),
this.membersService.buildRecentMembersFilter(queryParams)
this.membersService.buildRecentMembersFilter(queryParams),
this.membersService.buildParticipationTypeFilter(queryParams)
],
};
return await this.membersService.getMemberFilters(builtQuery);
Expand Down
4 changes: 2 additions & 2 deletions apps/web-api/src/members/members.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export class MembersService {
slugURL: true,
startDate: true,
endDate: true,
location:{
location: {
select: {
location: true,
timezone: true,
Expand Down Expand Up @@ -1185,7 +1185,7 @@ export class MembersService {
tx
);
}));

return result;
});
await this.cacheService.reset({ service: 'members' });
Expand Down
8 changes: 6 additions & 2 deletions apps/web-api/src/teams/teams.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ export class TeamsController {
);
const builder = new PrismaQueryBuilder(queryableFields);
const builtQuery = builder.build(request.query);
const { focusAreas }: any = request.query;
const { focusAreas, isHost } : any = request.query;
if(isHost) { //Remove isHost from the default query since it is to be added in eventGuest.
delete builtQuery.where?.isHost;
}
builtQuery.where = {
AND: [
builtQuery.where ? builtQuery.where : {},
this.teamsService.buildFocusAreaFilters(focusAreas),
this.teamsService.buildRecentTeamsFilter(request.query)
this.teamsService.buildRecentTeamsFilter(request.query),
this.teamsService.buildParticipationTypeFilter(request.query)
]
}
return this.teamsService.findAll(builtQuery);
Expand Down
2 changes: 1 addition & 1 deletion apps/web-api/src/teams/teams.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class TeamsService {
slugURL: true,
startDate: true,
endDate: true,
location:{
location: {
select: {
location: true,
timezone: true,
Expand Down
Loading