Skip to content

Commit

Permalink
Merge pull request #1159 from tekdi/release-2.1.2
Browse files Browse the repository at this point in the history
Merge `release-2.1.2` into `Master`
  • Loading branch information
sagarkoshti1990 authored May 23, 2024
2 parents 883b0dd + a44169d commit a0f58b4
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/src/events/events.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,22 @@ export class EventsService {

async getParticipants(req, id, body, res) {
const auth_users = await this.userService.ipUserInfo(req, 'staff');
let variables = {};
let limitquery = '';
let limitvariables = '';

const page = isNaN(body?.page) ? 1 : parseInt(body?.page);
const limit = isNaN(body?.limit) ? 6 : parseInt(body?.limit);
const offset = page > 1 ? limit * (page - 1) : 0;
if (!isNaN(body?.limit)) {
limitquery = `limit: $limit,offset: $offset`;
limitvariables = `($limit: Int, $offset: Int)`;
variables = {
limit: limit,
offset: offset,
};
}

let facilitator_id;
let searchQuery = '';

Expand All @@ -812,14 +824,13 @@ export class EventsService {
}

const data = {
query: `query MyQuery($limit: Int, $offset: Int) {
query: `query MyQuery${limitvariables} {
users_aggregate(where: {program_faciltators: {id: {_is_null: false}, parent_ip: {_eq: "${auth_users?.data?.program_users[0]?.organisation_id}"}},attendances: {context: {_eq: "events"}, context_id: {_eq: ${id}}}}) {
aggregate {
count
}
}
users(where: {${searchQuery}program_faciltators: {id: {_is_null: false}, parent_ip: {_eq: "${auth_users?.data?.program_users[0]?.organisation_id}"}}, attendances: {context: {_eq: "events"}, context_id: {_eq: ${id}}}}, limit: $limit,
offset: $offset${order_by}) {
users(where: {${searchQuery}program_faciltators: {id: {_is_null: false}, parent_ip: {_eq: "${auth_users?.data?.program_users[0]?.organisation_id}"}}, attendances: {context: {_eq: "events"}, context_id: {_eq: ${id}}}}, ${limitquery} ${order_by}) {
id
first_name
middle_name
Expand Down Expand Up @@ -858,10 +869,7 @@ export class EventsService {
}
}
`,
variables: {
limit: limit,
offset: offset,
},
variables,
};
const result = await this.hasuraServiceFromServices.getData(data);
const count = result?.data?.users_aggregate?.aggregate?.count;
Expand Down

0 comments on commit a0f58b4

Please sign in to comment.