fix: export preview missing athleteName and timeSlot data

- JOIN martial_athlete table to get player names
- Calculate timeSlot from time_slot_index (0=08:30, 1=13:30, 2=18:30)
- Use COALESCE to fallback to athlete table when participant name is null

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
2026-01-16 12:44:05 +08:00
co-authored by factory-droid[bot]
parent af513ce83a
commit b95c038971
@@ -16,7 +16,18 @@
d.id AS detailId,
d.venue_id AS venueId,
d.venue_name AS venueName,
d.time_slot AS timeSlot,
COALESCE(NULLIF(d.time_slot, ''),
CASE
WHEN d.time_slot_index IS NOT NULL THEN
CASE d.time_slot_index % 3
WHEN 0 THEN '08:30'
WHEN 1 THEN '13:30'
WHEN 2 THEN '18:30'
ELSE '08:30'
END
ELSE ''
END
) AS timeSlot,
d.time_slot_index AS timeSlotIndex,
d.schedule_date AS scheduleDate,
p.participant_id AS participantId,
@@ -24,13 +35,15 @@
p.check_in_status AS checkInStatus,
p.schedule_status AS scheduleStatus,
p.performance_order AS performanceOrder,
p.player_name AS playerName
COALESCE(p.player_name, ma.player_name) AS playerName
FROM
martial_schedule_group g
LEFT JOIN
martial_schedule_detail d ON g.id = d.schedule_group_id AND d.is_deleted = 0
LEFT JOIN
martial_schedule_participant p ON g.id = p.schedule_group_id AND p.is_deleted = 0
LEFT JOIN
martial_athlete ma ON p.participant_id = ma.id AND ma.is_deleted = 0
WHERE
g.competition_id = #{competitionId}
AND g.is_deleted = 0