Fix penalty on Excel

This commit is contained in:
2024-11-11 00:37:10 +09:00
parent 10bf6e8fa1
commit 158dbeee40

View File

@ -64,7 +64,7 @@ WITH completion_status AS (
-- 遅刻ペナルティの計算1秒でも遅れたら、その分数に応じて-50点/分)
CASE
WHEN gi.goaltime > ev.end_datetime THEN
(CEIL(EXTRACT(EPOCH FROM (gi.goaltime - ev.end_datetime)) / 60)) * 50
(CEIL(EXTRACT(EPOCH FROM (gi.goaltime - ev.end_datetime)) / 60)) * (-50)
ELSE 0
END as late_penalty_points,
gi.goaltime,
@ -83,10 +83,7 @@ points_calculation AS (
SELECT
*,
-- 総合ポイントの再計算(遅刻ペナルティを含む)
GREATEST(
raw_points - late_penalty_points,
0
) as total_points
raw_points + late_penalty_points as total_points
FROM completion_status
),
valid_rankings AS (
@ -172,12 +169,13 @@ SELECT
cu.female as owner_is_female,
-- スコア情報
COALESCE(cs.total_points, 0) as total_points,
COALESCE(cs.normal_points, 0) as normal_points,
COALESCE(cs.bonus_points, 0) as bonus_points,
COALESCE(cs.penalty_points, 0) as penalty_points,
COALESCE(cs.total_checkins, 0) as checkin_count,
COALESCE(cs.purchase_count, 0) as purchase_count,
cr.late_penalty_points as penalty_points, -- 遅刻ペナルティを使用
cr.total_points as total_points, -- v_category_rankingsの総合ポイントを使用
-- ゴール情報
gi.goalimage as goal_image,
@ -241,7 +239,8 @@ GROUP BY
cu.email, cu.firstname, cu.lastname, cu.date_of_birth, cu.female,
cs.total_points, cs.normal_points, cs.bonus_points, cs.penalty_points,
cs.total_checkins, cs.purchase_count, cs.last_checkin,
cr.ranking, cr.total_valid_participants,
cr.original_total_points, cr.late_penalty_points, cr.total_points,
cr.completion_status, cr.ranking, cr.total_valid_participants,
gi.goalimage, gi.goaltime,
e.owner_id;