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 #211525 [BE] : Camp Session -> Session activity is not working as expected for 1.5 days #1013

Open
wants to merge 1 commit into
base: release-2.8.4
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions src/src/sessions/sessions.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,21 @@ export class SessionsController {
response,
);
}

@Post('/session-wegithage/:id')
@UsePipes(ValidationPipe)
@UseGuards(new AuthGuard())
getSessionWegithage(
@Req() request: any,
@Res() response: Response,
@Param('id') id: number,
@Body() body: any,
) {
return this.sessionService.getSessionWegithage(
id,
body,
request,
response,
);
}
}
47 changes: 47 additions & 0 deletions src/src/sessions/sessions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,51 @@ export class SessionsService {
});
}
}

public async getSessionWegithage(
id: any,
bodyData: any,
request: any,
response: any,
) {
const camp_id = id;

const data = `SELECT
camp_id,
learning_lesson_plan_id,
MAX(CASE
WHEN DATE(created_at) < CURRENT_DATE AND DATE(updated_at) = CURRENT_DATE THEN 0.5
WHEN DATE(created_at) = CURRENT_DATE AND DATE(updated_at) = CURRENT_DATE THEN 1
WHEN DATE(created_at) = CURRENT_DATE AND DATE(updated_at) > CURRENT_DATE THEN 0.5
ELSE 0
END) AS weightage_completed
FROM
learning_sessions_tracker
WHERE
camp_id = ${camp_id} and DATE(created_at) = CURRENT_DATE or DATE(updated_at) = CURRENT_DATE
GROUP BY
camp_id,
learning_lesson_plan_id`;
const result = (
await this.hasuraServiceFromServices.executeRawSql(data)
).result;
const wegithagerusult =
this.hasuraServiceFromServices.getFormattedData(result);

if (wegithagerusult) {
return response.json({
status: 200,
success: true,
message: 'Successfully retrieved data',
data: wegithagerusult,
});
} else {
return response.json({
status: 500,
success: false,
message: 'Error retrieving data',
data: {},
});
}
}
Tusharmahajan12 marked this conversation as resolved.
Show resolved Hide resolved
}