mend
merge from master
This commit is contained in:
parent
889c3ebb35
commit
913f4dea7c
@ -699,37 +699,28 @@ _rowUserSemester = _userTableFeatures . _1 . _Just . _studyFeaturesSemester
|
||||
|
||||
|
||||
-- Sql-Getters for this query, used for sorting and filtering (cannot be lenses due to being Esqueleto expressions)
|
||||
-- This ought to ease refactoring the query
|
||||
queryUser :: UserTableExpr -> E.SqlExpr (Entity User)
|
||||
queryUser ((user `E.InnerJoin` _participant) `E.LeftOuterJoin` _note `E.LeftOuterJoin` _studyFeatures) = user
|
||||
queryUser = $(sqlIJproj 2 1) . $(sqlLOJproj 3 1)
|
||||
|
||||
-- No longer needed:
|
||||
-- queryUserName :: UserTableExpr -> E.SqlExpr (E.Value Text)
|
||||
-- queryUserName ((user `E.InnerJoin` _participant) `E.LeftOuterJoin` _note `E.LeftOuterJoin` _studyFeatures) = user E.^. UserDisplayName
|
||||
|
||||
-- queryUserDisplayName :: UserTableExpr -> E.SqlExpr (E.Value Text)
|
||||
-- queryUserDisplayName ((user `E.InnerJoin` _participant) `E.LeftOuterJoin` _note `E.LeftOuterJoin` _studyFeatures) = user E.^. UserDisplayName
|
||||
queryParticipant :: UserTableExpr -> E.SqlExpr (Entity CourseParticipant)
|
||||
queryParticipant = $(sqlIJproj 2 2) . $(sqlLOJproj 3 1)
|
||||
|
||||
queryUserNote :: UserTableExpr -> E.SqlExpr (Maybe (Entity CourseUserNote))
|
||||
queryUserNote ((_user `E.InnerJoin` _participant) `E.LeftOuterJoin` note `E.LeftOuterJoin` _studyFeatures) = note
|
||||
queryUserNote = $(sqlLOJproj 3 2)
|
||||
|
||||
queryUserFeatures :: UserTableExpr -> (E.SqlExpr (Maybe (Entity StudyFeatures)) `E.InnerJoin` E.SqlExpr (Maybe (Entity StudyDegree)) `E.InnerJoin`E.SqlExpr (Maybe (Entity StudyTerms)))
|
||||
queryUserFeatures ((_user `E.InnerJoin` _participant) `E.LeftOuterJoin` _note `E.LeftOuterJoin` studyFeatures) = studyFeatures
|
||||
queryUserFeatures = $(sqlLOJproj 3 3)
|
||||
|
||||
queryFeaturesStudy :: (a `E.InnerJoin` b `E.InnerJoin` c) -> a
|
||||
queryFeaturesStudy = $(sqlIJproj 3 1)
|
||||
|
||||
queryFeaturesDegree :: (a `E.InnerJoin` b `E.InnerJoin` c) -> b
|
||||
queryFeaturesDegree = $(sqlIJproj 3 2)
|
||||
|
||||
queryFeaturesField :: (a `E.InnerJoin` b `E.InnerJoin` c) -> c
|
||||
queryFeaturesField = $(sqlIJproj 3 3)
|
||||
queryFeaturesField = $(sqlIJproj 3 3)
|
||||
|
||||
queryUserSemester :: UserTableExpr -> E.SqlExpr (E.Value (Maybe Int)) -- (E.Value (Maybe Int))
|
||||
queryUserSemester = aux . queryUserFeatures
|
||||
where aux (features `E.InnerJoin` _degree `E.InnerJoin` _terms)
|
||||
= features E.?. StudyFeaturesSemester
|
||||
|
||||
-- Deprecated in favour of newer implementation
|
||||
-- queryUserSemester :: UserTableExpr -> E.SqlExpr (E.Value (Maybe Int)) -- (E.Value (Maybe Int))
|
||||
-- queryUserSemester ((_user `E.InnerJoin` _participant) `E.LeftOuterJoin` _note `E.LeftOuterJoin` (features `E.InnerJoin` _degree `E.InnerJoin` _terms) )
|
||||
-- = features E.?. StudyFeaturesSemester
|
||||
|
||||
colUserComment :: IsDBTable m c => TermId -> SchoolId -> CourseShorthand -> Colonnade Sortable UserTableData (DBCell m c)
|
||||
colUserComment tid ssh csh =
|
||||
@ -779,7 +770,8 @@ makeCourseUserTable cid colChoices psValidator =
|
||||
, ("course-user-degree-short", SortColumn $ queryUserFeatures >>> queryFeaturesDegree >>> (E.?. StudyDegreeShorthand))
|
||||
, ("course-user-field" , SortColumn $ queryUserFeatures >>> queryFeaturesField >>> (E.?. StudyTermsName))
|
||||
, ("course-user-field-short" , SortColumn $ queryUserFeatures >>> queryFeaturesField >>> (E.?. StudyTermsShorthand))
|
||||
, ("course-user-semesternr" , SortColumn queryUserSemester) -- $ -- preview (_userTableFeatures . _1 . _Just . _studyFeaturesSemester))
|
||||
, ("course-user-semesternr" , SortColumn $ queryUserFeatures >>> queryFeaturesStudy >>> (E.?. StudyFeaturesSemester))
|
||||
, ("course-registration" , SortColumn $ queryParticipant >>> (E.^. CourseParticipantRegistration))
|
||||
, ("course-user-note" , SortColumn $ queryUserNote >>> \note -> -- sort by last edit date
|
||||
E.sub_select . E.from $ \edit -> do
|
||||
E.where_ $ note E.?. CourseUserNoteId E.==. E.just (edit E.^. CourseUserNoteEditNote)
|
||||
@ -792,7 +784,8 @@ makeCourseUserTable cid colChoices psValidator =
|
||||
, fltrUserMatriclenr queryUser
|
||||
, ("course-user-degree", error "TODO") -- TODO
|
||||
, ("course-user-field" , error "TODO") -- TODO
|
||||
, ("course-user-semesternr", FilterColumn $ mkExactFilter queryUserSemester)
|
||||
, ("course-user-semesternr", FilterColumn $ mkExactFilter $ queryUserFeatures >>> queryFeaturesStudy >>> (E.?. StudyFeaturesSemester))
|
||||
, ("course-registration", error "TODO") -- TODO
|
||||
, ("course-user-note", error "TODO") -- TODO
|
||||
]
|
||||
dbtFilterUI = mempty -- TODO
|
||||
@ -811,7 +804,7 @@ getCUsersR tid ssh csh = do
|
||||
, colUserDegreeShort
|
||||
, colUserFieldShort
|
||||
, colUserSemester
|
||||
, sortable (Just "registration") (i18nCell MsgRegisteredHeader) (dateCell . view _userTableRegistration)
|
||||
, sortable (Just "course-registration") (i18nCell MsgRegisteredHeader) (dateCell . view _userTableRegistration)
|
||||
, colUserComment tid ssh csh
|
||||
]
|
||||
psValidator = def & defaultSortingByName
|
||||
|
||||
Loading…
Reference in New Issue
Block a user