feat(allocations): include study features in users table
This commit is contained in:
parent
1012230f9a
commit
7f7d2c7957
@ -2689,6 +2689,7 @@ CsvColumnAllocationUserSurname: Nachname(n) des Bewerbers
|
|||||||
CsvColumnAllocationUserFirstName: Vorname(n) des Bewerbers
|
CsvColumnAllocationUserFirstName: Vorname(n) des Bewerbers
|
||||||
CsvColumnAllocationUserName: Voller Name des Bewerbers
|
CsvColumnAllocationUserName: Voller Name des Bewerbers
|
||||||
CsvColumnAllocationUserMatriculation: Matrikelnummer des Bewerber
|
CsvColumnAllocationUserMatriculation: Matrikelnummer des Bewerber
|
||||||
|
CsvColumnAllocationUserStudyFeatures: Studiendaten
|
||||||
CsvColumnAllocationUserRequested: Maximale Anzahl von Plätzen, die der Bewerber bereit ist, zu akzeptieren
|
CsvColumnAllocationUserRequested: Maximale Anzahl von Plätzen, die der Bewerber bereit ist, zu akzeptieren
|
||||||
CsvColumnAllocationUserApplied: Anzahl von Bewerbungen, die der Bewerber eingereicht hat
|
CsvColumnAllocationUserApplied: Anzahl von Bewerbungen, die der Bewerber eingereicht hat
|
||||||
CsvColumnAllocationUserVetos: Anzahl von Bewerbungen, die von Kursverwaltern ein Veto oder eine Note erhalten haben, die äquivalent ist zu "Nicht Bestanden" (5.0)
|
CsvColumnAllocationUserVetos: Anzahl von Bewerbungen, die von Kursverwaltern ein Veto oder eine Note erhalten haben, die äquivalent ist zu "Nicht Bestanden" (5.0)
|
||||||
|
|||||||
@ -2689,6 +2689,7 @@ CsvColumnAllocationUserSurname: Applicant's surname(s)
|
|||||||
CsvColumnAllocationUserFirstName: Applicants's first name(s)
|
CsvColumnAllocationUserFirstName: Applicants's first name(s)
|
||||||
CsvColumnAllocationUserName: Applicant's full name
|
CsvColumnAllocationUserName: Applicant's full name
|
||||||
CsvColumnAllocationUserMatriculation: Applicant's matriculation
|
CsvColumnAllocationUserMatriculation: Applicant's matriculation
|
||||||
|
CsvColumnAllocationUserStudyFeatures: Features of study
|
||||||
CsvColumnAllocationUserRequested: Maximum number of placements the applicant is prepared to accept
|
CsvColumnAllocationUserRequested: Maximum number of placements the applicant is prepared to accept
|
||||||
CsvColumnAllocationUserApplied: Number of applications the applicant has provided
|
CsvColumnAllocationUserApplied: Number of applications the applicant has provided
|
||||||
CsvColumnAllocationUserVetos: Number of applications that have received a veto from a course administrator or have been rated with a grade that is equivalent to "failed" (5.0)
|
CsvColumnAllocationUserVetos: Number of applications that have received a veto from a course administrator or have been rated with a grade that is equivalent to "failed" (5.0)
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import Handler.Allocation.Accept
|
|||||||
|
|
||||||
import Handler.Utils
|
import Handler.Utils
|
||||||
import Handler.Utils.Allocation
|
import Handler.Utils.Allocation
|
||||||
|
import Handler.Utils.StudyFeatures
|
||||||
|
|
||||||
import qualified Database.Esqueleto as E
|
import qualified Database.Esqueleto as E
|
||||||
import qualified Database.Esqueleto.Utils as E
|
import qualified Database.Esqueleto.Utils as E
|
||||||
@ -59,6 +60,7 @@ queryVetoedCourses = queryAllocationUser . to queryVetoedCourses'
|
|||||||
|
|
||||||
|
|
||||||
type UserTableData = DBRow ( Entity User
|
type UserTableData = DBRow ( Entity User
|
||||||
|
, UserTableStudyFeatures
|
||||||
, Entity AllocationUser
|
, Entity AllocationUser
|
||||||
, Int -- ^ Applied
|
, Int -- ^ Applied
|
||||||
, Int -- ^ Assigned
|
, Int -- ^ Assigned
|
||||||
@ -68,13 +70,16 @@ type UserTableData = DBRow ( Entity User
|
|||||||
resultUser :: Lens' UserTableData (Entity User)
|
resultUser :: Lens' UserTableData (Entity User)
|
||||||
resultUser = _dbrOutput . _1
|
resultUser = _dbrOutput . _1
|
||||||
|
|
||||||
|
resultStudyFeatures :: Lens' UserTableData UserTableStudyFeatures
|
||||||
|
resultStudyFeatures = _dbrOutput . _2
|
||||||
|
|
||||||
resultAllocationUser :: Lens' UserTableData (Entity AllocationUser)
|
resultAllocationUser :: Lens' UserTableData (Entity AllocationUser)
|
||||||
resultAllocationUser = _dbrOutput . _2
|
resultAllocationUser = _dbrOutput . _3
|
||||||
|
|
||||||
resultAppliedCourses, resultAssignedCourses, resultVetoedCourses :: Lens' UserTableData Int
|
resultAppliedCourses, resultAssignedCourses, resultVetoedCourses :: Lens' UserTableData Int
|
||||||
resultAppliedCourses = _dbrOutput . _3
|
resultAppliedCourses = _dbrOutput . _4
|
||||||
resultAssignedCourses = _dbrOutput . _4
|
resultAssignedCourses = _dbrOutput . _5
|
||||||
resultVetoedCourses = _dbrOutput . _5
|
resultVetoedCourses = _dbrOutput . _6
|
||||||
|
|
||||||
|
|
||||||
data AllocationUserTableCsv = AllocationUserTableCsv
|
data AllocationUserTableCsv = AllocationUserTableCsv
|
||||||
@ -82,6 +87,7 @@ data AllocationUserTableCsv = AllocationUserTableCsv
|
|||||||
, csvAUserFirstName :: Text
|
, csvAUserFirstName :: Text
|
||||||
, csvAUserName :: Text
|
, csvAUserName :: Text
|
||||||
, csvAUserMatriculation :: Maybe Text
|
, csvAUserMatriculation :: Maybe Text
|
||||||
|
, csvAUserStudyFeatures :: UserTableStudyFeatures
|
||||||
, csvAUserRequested
|
, csvAUserRequested
|
||||||
, csvAUserApplied
|
, csvAUserApplied
|
||||||
, csvAUserVetos
|
, csvAUserVetos
|
||||||
@ -105,6 +111,7 @@ instance CsvColumnsExplained AllocationUserTableCsv where
|
|||||||
, singletonMap 'csvAUserFirstName MsgCsvColumnAllocationUserFirstName
|
, singletonMap 'csvAUserFirstName MsgCsvColumnAllocationUserFirstName
|
||||||
, singletonMap 'csvAUserName MsgCsvColumnAllocationUserName
|
, singletonMap 'csvAUserName MsgCsvColumnAllocationUserName
|
||||||
, singletonMap 'csvAUserMatriculation MsgCsvColumnAllocationUserMatriculation
|
, singletonMap 'csvAUserMatriculation MsgCsvColumnAllocationUserMatriculation
|
||||||
|
, singletonMap 'csvAUserStudyFeatures MsgCsvColumnAllocationUserStudyFeatures
|
||||||
, singletonMap 'csvAUserRequested MsgCsvColumnAllocationUserRequested
|
, singletonMap 'csvAUserRequested MsgCsvColumnAllocationUserRequested
|
||||||
, singletonMap 'csvAUserApplied MsgCsvColumnAllocationUserApplied
|
, singletonMap 'csvAUserApplied MsgCsvColumnAllocationUserApplied
|
||||||
, singletonMap 'csvAUserVetos MsgCsvColumnAllocationUserVetos
|
, singletonMap 'csvAUserVetos MsgCsvColumnAllocationUserVetos
|
||||||
@ -148,13 +155,15 @@ postAUsersR tid ssh ash = do
|
|||||||
, assigned
|
, assigned
|
||||||
, vetoed)
|
, vetoed)
|
||||||
dbtRowKey = views queryAllocationUser (E.^. AllocationUserId)
|
dbtRowKey = views queryAllocationUser (E.^. AllocationUserId)
|
||||||
dbtProj = runReaderT $ (asks . set _dbrOutput) <=< magnify _dbrOutput $
|
dbtProj = runReaderT $ (asks . set _dbrOutput) <=< magnify _dbrOutput $ do
|
||||||
(,,,,)
|
feats <- lift . allocationUserStudyFeatures aId =<< views _1 entityKey
|
||||||
<$> view _1 <*> view _2 <*> view (_3 . _Value) <*> view (_4 . _Value) <*> view (_5 . _Value)
|
(,,,,,)
|
||||||
|
<$> view _1 <*> pure feats <*> view _2 <*> view (_3 . _Value) <*> view (_4 . _Value) <*> view (_5 . _Value)
|
||||||
dbtColonnade :: Colonnade Sortable _ _
|
dbtColonnade :: Colonnade Sortable _ _
|
||||||
dbtColonnade = mconcat . catMaybes $
|
dbtColonnade = mconcat . catMaybes $
|
||||||
[ pure $ colUserDisplayName (resultUser . _entityVal . $(multifocusL 2) _userDisplayName _userSurname)
|
[ pure $ colUserDisplayName (resultUser . _entityVal . $(multifocusL 2) _userDisplayName _userSurname)
|
||||||
, pure $ colUserMatriculation (resultUser . _entityVal . _userMatrikelnummer)
|
, pure $ colUserMatriculation (resultUser . _entityVal . _userMatrikelnummer)
|
||||||
|
, pure $ colStudyFeatures resultStudyFeatures
|
||||||
, pure $ colAllocationRequested (resultAllocationUser . _entityVal . _allocationUserTotalCourses)
|
, pure $ colAllocationRequested (resultAllocationUser . _entityVal . _allocationUserTotalCourses)
|
||||||
, pure . coursesModalApplied $ colAllocationApplied resultAppliedCourses
|
, pure . coursesModalApplied $ colAllocationApplied resultAppliedCourses
|
||||||
, pure . coursesModalVetoed $ colAllocationVetoed resultVetoedCourses
|
, pure . coursesModalVetoed $ colAllocationVetoed resultVetoedCourses
|
||||||
@ -258,6 +267,7 @@ postAUsersR tid ssh ash = do
|
|||||||
<*> view (resultUser . _entityVal . _userFirstName)
|
<*> view (resultUser . _entityVal . _userFirstName)
|
||||||
<*> view (resultUser . _entityVal . _userDisplayName)
|
<*> view (resultUser . _entityVal . _userDisplayName)
|
||||||
<*> view (resultUser . _entityVal . _userMatrikelnummer)
|
<*> view (resultUser . _entityVal . _userMatrikelnummer)
|
||||||
|
<*> view resultStudyFeatures
|
||||||
<*> view (resultAllocationUser . _entityVal . _allocationUserTotalCourses)
|
<*> view (resultAllocationUser . _entityVal . _allocationUserTotalCourses)
|
||||||
<*> view (resultAppliedCourses . to fromIntegral)
|
<*> view (resultAppliedCourses . to fromIntegral)
|
||||||
<*> view (resultVetoedCourses . to fromIntegral)
|
<*> view (resultVetoedCourses . to fromIntegral)
|
||||||
|
|||||||
@ -9,6 +9,7 @@ module Handler.Utils.StudyFeatures
|
|||||||
, isCourseStudyFeature, courseUserStudyFeatures
|
, isCourseStudyFeature, courseUserStudyFeatures
|
||||||
, isExternalExamStudyFeature, externalExamUserStudyFeatures
|
, isExternalExamStudyFeature, externalExamUserStudyFeatures
|
||||||
, isTermStudyFeature
|
, isTermStudyFeature
|
||||||
|
, isAllocationStudyFeature, allocationUserStudyFeatures
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Import.NoFoundation
|
import Import.NoFoundation
|
||||||
@ -184,3 +185,24 @@ externalExamUserStudyFeatures eeId uid = do
|
|||||||
|
|
||||||
isTermStudyFeature :: E.SqlExpr (Entity Term) -> E.SqlExpr (Entity StudyFeatures) -> E.SqlExpr (E.Value Bool)
|
isTermStudyFeature :: E.SqlExpr (Entity Term) -> E.SqlExpr (Entity StudyFeatures) -> E.SqlExpr (E.Value Bool)
|
||||||
isTermStudyFeature = isRelevantStudyFeatureCached TermId
|
isTermStudyFeature = isRelevantStudyFeatureCached TermId
|
||||||
|
|
||||||
|
|
||||||
|
isAllocationStudyFeature :: E.SqlExpr (Entity Allocation) -> E.SqlExpr (Entity StudyFeatures) -> E.SqlExpr (E.Value Bool)
|
||||||
|
isAllocationStudyFeature = isRelevantStudyFeatureCached AllocationTerm
|
||||||
|
|
||||||
|
allocationUserStudyFeatures :: MonadIO m => AllocationId -> UserId -> SqlPersistT m UserTableStudyFeatures
|
||||||
|
allocationUserStudyFeatures aId uid = do
|
||||||
|
feats <- E.select . E.from $ \(allocation `E.InnerJoin` studyFeatures `E.InnerJoin` terms `E.InnerJoin` degree) -> do
|
||||||
|
E.on $ degree E.^. StudyDegreeId E.==. studyFeatures E.^. StudyFeaturesDegree
|
||||||
|
E.on $ terms E.^. StudyTermsId E.==. studyFeatures E.^. StudyFeaturesField
|
||||||
|
E.on $ isAllocationStudyFeature allocation studyFeatures
|
||||||
|
E.where_ $ allocation E.^. AllocationId E.==. E.val aId
|
||||||
|
E.where_ $ studyFeatures E.^. StudyFeaturesUser E.==. E.val uid
|
||||||
|
return (terms, degree, studyFeatures)
|
||||||
|
return . UserTableStudyFeatures . Set.fromList . flip map feats $
|
||||||
|
\(Entity _ StudyTerms{..}, Entity _ StudyDegree{..}, Entity _ StudyFeatures{..}) -> UserTableStudyFeature
|
||||||
|
{ userTableField = fromMaybe (tshow studyTermsKey) studyTermsName
|
||||||
|
, userTableDegree = fromMaybe (tshow studyDegreeKey) studyDegreeName
|
||||||
|
, userTableSemester = studyFeaturesSemester
|
||||||
|
, userTableFieldType = studyFeaturesType
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user