fix(course-users): add missing dbt sorting

This commit is contained in:
Sarah Vaupel 2020-03-02 15:00:40 +01:00 committed by Gregor Kleen
parent 34ad1dfae2
commit 1bc14c9e19

View File

@ -89,7 +89,6 @@ instance HasEntity UserTableData User where
hasEntity = _dbrOutput . _1
instance HasUser UserTableData where
-- hasUser = _entityVal
hasUser = _dbrOutput . _1 . _entityVal
_userTableRegistration :: Lens' UserTableData UTCTime
@ -334,6 +333,13 @@ makeCourseUserTable cid acts restrict colChoices psValidator csvColumns = do
E.where_ $ participant E.^. TutorialParticipantUser E.==. user E.^. UserId
return . E.min_ $ tutorial E.^. TutorialName
)
, single $ ("exams" , SortColumn $ queryUser >>> \user ->
E.subSelectMaybe . E.from $ \(exam `E.InnerJoin` examRegistration) -> do
E.on $ exam E.^. ExamId E.==. examRegistration E.^. ExamRegistrationExam
E.&&. exam E.^. ExamCourse E.==. E.val cid
E.where_ $ examRegistration E.^. ExamRegistrationUser E.==. user E.^. UserId
return . E.min_ $ exam E.^. ExamName
)
]
where single = uncurry Map.singleton
dbtFilter = mconcat