Skip to content

Commit

Permalink
🐛 fix: add dynamic query to user_total_xp
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenyiCui committed Nov 10, 2022
1 parent cbdd4db commit 97a69ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/cadet_web/admin_controllers/admin_user_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ defmodule CadetWeb.AdminUserController do
end

def combined_user_total_xp(conn, _) do
course_id = conn.assigns.course_reg.course_id

combined_user_xp_total_query = """
SELECT
name,
Expand Down Expand Up @@ -325,7 +327,7 @@ defmodule CadetWeb.AdminUserController do
FROM
course_registrations cr
WHERE
cr.course_id = 41
cr.course_id = #{course_id}
) cr_ids on cr_ids.id = submissions.student_id
) as ss0
INNER JOIN "answers" sa1 ON ss0."id" = sa1."submission_id"
Expand Down Expand Up @@ -354,7 +356,7 @@ defmodule CadetWeb.AdminUserController do
INNER JOIN "goals" AS sg2 ON sg2."uuid" = sa1."goal_uuid"
RIGHT OUTER JOIN "goal_progress" AS sg3 ON (sg3."goal_uuid" = sg2."uuid")
WHERE
(sa0."course_id" = 41)
(sa0."course_id" = #{course_id})
GROUP BY
sa0."uuid",
sg3."course_reg_id"
Expand Down

0 comments on commit 97a69ee

Please sign in to comment.