Skip to content

Commit 6405538

Browse files
committed
Move anonymous function out of inline
1 parent e0c2f03 commit 6405538

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/cadet/assessments/assessments.ex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,18 @@ defmodule Cadet.Assessments do
147147
end
148148

149149
def all_user_total_xp(course_id, options \\ %{}) do
150+
include_admin_staff_users = fn q ->
151+
if options[:include_admin_staff],
152+
do: q,
153+
else: where(q, [_, cr], cr.role == "student")
154+
end
155+
150156
# get all users even if they have 0 xp
151157
course_userid_query =
152158
User
153159
|> join(:inner, [u], cr in CourseRegistration, on: cr.user_id == u.id)
154160
|> where([_, cr], cr.course_id == ^course_id)
155-
|> (fn q ->
156-
if options[:include_admin_staff],
157-
do: q,
158-
else: where(q, [_, cr], cr.role == "student")
159-
end).()
161+
|> include_admin_staff_users.()
160162
|> select([u, cr], %{
161163
id: u.id,
162164
cr_id: cr.id

0 commit comments

Comments
 (0)