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

Task #218840 corrected the response of getStatusWiseCount of camp module #1113

Open
wants to merge 2 commits into
base: release-2.8.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/src/camp/camp.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class CampModule implements NestModule {
path: '/camp/attendance/:id',
method: RequestMethod.POST,
},
'/camp/getStatusWiseCount',

{
path: '/camp/admin/facilitator-reassign/:id',
method: RequestMethod.PATCH,
Expand Down
37 changes: 30 additions & 7 deletions src/src/camp/camp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2760,15 +2760,38 @@ export class CampService {
.data.map((item) => item.value);

const variables: any = {};
if (req.mw_roles?.includes('program_owner')) {
req.parent_ip_id = req.mw_ip_user_id;
} else {
const user = await this.userService.ipUserInfo(req);
if (req.mw_roles?.includes('staff')) {
req.parent_ip_id =
user?.data?.program_users?.[0]?.organisation_id;
} else if (req.mw_roles?.includes('facilitator')) {
req.parent_ip_id = user?.data?.program_faciltators?.parent_ip;
}
}
if (!req.parent_ip_id) {
return resp.status(404).send({
success: false,
message: 'Invalid Ip',
data: {},
});
}

let filterQueryArray = [];
const program_id = req.mw_program_id;
const academic_year_id = req.mw_academic_year_id;
const parent_ip_id = req?.parent_ip_id;

const filterQueryArray = [
`{group_users: {member_type: {_eq: "owner"}, group: {program_id: {_eq:${program_id}}, academic_year_id: {_eq:${academic_year_id}}},user:{program_faciltators:{parent_ip:{_eq:"${parent_ip_id}"}}}}}`,
];
if (body.search && body.search !== '') {
filterQueryArray.push(`{_or: [
{ first_name: { _ilike: "%${body.search}%" } },
{ last_name: { _ilike: "%${body.search}%" } },
{ email_id: { _ilike: "%${body.search}%" } }
]} `);
{ first_name: { _ilike: "%${body.search}%" } },
{ last_name: { _ilike: "%${body.search}%" } },
{ email_id: { _ilike: "%${body.search}%" } }
]}`);
}

if (body?.district && body?.district.length > 0) {
Expand All @@ -2792,8 +2815,8 @@ export class CampService {
);
}

let filterQuery = '{ _and: [' + filterQueryArray.join(',') + '] }';

const filterQuery = '{ _and: [' + filterQueryArray.join(',') + '] }';
console.log('filterQuery', filterQuery);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing debug statements like console.log from production code to maintain cleanliness and security.

- console.log('filterQuery', filterQuery);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
console.log('filterQuery', filterQuery);

Remove debug statements like console.log from production code to enhance security and performance.

- console.log('filterQuery', filterQuery);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
console.log('filterQuery', filterQuery);

Remove debug statements like console.log from production code to enhance security and performance.

- console.log('filterQuery', filterQuery);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
console.log('filterQuery', filterQuery);

const response = await this.campcoreservice.getStatuswiseCount(
filterQuery,
filterQueryArray,
Expand Down