added member names to training reports

This commit is contained in:
2025-11-17 11:57:25 -05:00
parent 750ee5f02c
commit 2eeb62cf3c
3 changed files with 21 additions and 12 deletions

View File

@@ -18,7 +18,7 @@ function buildAttendee(row: RawAttendeeRow): CourseAttendee {
updated_at: row.updated_at,
remarks: row.remarks,
attendee_role_id: row.attendee_role_id,
attendee_name: row.attendee_name,
role: row.role_id
? {
id: row.role_id,
@@ -35,6 +35,7 @@ function buildAttendee(row: RawAttendeeRow): CourseAttendee {
export async function getCourseEventAttendees(id: number): Promise<CourseAttendee[]> {
const sql = `SELECT
ca.*,
mem.name AS attendee_name,
ar.id AS role_id,
ar.name AS role_name,
ar.description AS role_description,
@@ -43,6 +44,7 @@ export async function getCourseEventAttendees(id: number): Promise<CourseAttende
ar.updated_at AS role_updated_at
FROM course_attendees ca
LEFT JOIN course_attendee_roles ar ON ar.id = ca.attendee_role_id
LEFT JOIN members mem ON ca.attendee_id = mem.id
WHERE ca.course_event_id = ?;`;
const res: RawAttendeeRow[] = await pool.query(sql, [id]);