feat(study-features): add study-features-first-observed
This commit is contained in:
parent
2823c7d827
commit
dcb83d96fc
@ -58,8 +58,9 @@ StudyFeatures -- multiple entries possible for students pursuing several degree
|
|||||||
superField StudyTermsId Maybe
|
superField StudyTermsId Maybe
|
||||||
type StudyFieldType -- Major or minor, i.e. Haupt-/Nebenfach
|
type StudyFieldType -- Major or minor, i.e. Haupt-/Nebenfach
|
||||||
semester Int
|
semester Int
|
||||||
updated UTCTime default=now() -- last update from LDAP
|
firstObserved UTCTime Maybe
|
||||||
valid Bool default=true -- marked as active in LDAP (students may switch, but LDAP never forgets)
|
lastObserved UTCTime default=now() -- last update from LDAP
|
||||||
|
valid Bool default=true
|
||||||
UniqueStudyFeatures user degree field type semester
|
UniqueStudyFeatures user degree field type semester
|
||||||
deriving Eq Show
|
deriving Eq Show
|
||||||
-- UniqueUserSubject ubuser degree field -- There exists a counterexample
|
-- UniqueUserSubject ubuser degree field -- There exists a counterexample
|
||||||
|
|||||||
@ -321,7 +321,7 @@ upsertCampusUser plugin ldapData = do
|
|||||||
, Just defType <- studyTermsDefaultType
|
, Just defType <- studyTermsDefaultType
|
||||||
-> do
|
-> do
|
||||||
$logDebugS "Campus" [st|Applying default for standalone study term “#{tshow subterm}”|]
|
$logDebugS "Campus" [st|Applying default for standalone study term “#{tshow subterm}”|]
|
||||||
(:) (StudyFeatures userId defDegree subterm Nothing defType subSemester now True) <$> assimilateSubTerms subterms unusedFeats
|
(:) (StudyFeatures userId defDegree subterm Nothing defType subSemester (Just now) now True) <$> assimilateSubTerms subterms unusedFeats
|
||||||
Nothing
|
Nothing
|
||||||
| [] <- unusedFeats -> do
|
| [] <- unusedFeats -> do
|
||||||
$logDebugS "Campus" [st|Saw subterm “#{tshow subterm}” when no fos-terms remain|]
|
$logDebugS "Campus" [st|Saw subterm “#{tshow subterm}” when no fos-terms remain|]
|
||||||
@ -389,26 +389,11 @@ upsertCampusUser plugin ldapData = do
|
|||||||
forM_ fs $ \f@StudyFeatures{..} -> do
|
forM_ fs $ \f@StudyFeatures{..} -> do
|
||||||
insertMaybe studyFeaturesDegree $ StudyDegree (unStudyDegreeKey studyFeaturesDegree) Nothing Nothing
|
insertMaybe studyFeaturesDegree $ StudyDegree (unStudyDegreeKey studyFeaturesDegree) Nothing Nothing
|
||||||
insertMaybe studyFeaturesField $ StudyTerms (unStudyTermsKey studyFeaturesField) Nothing Nothing Nothing Nothing
|
insertMaybe studyFeaturesField $ StudyTerms (unStudyTermsKey studyFeaturesField) Nothing Nothing Nothing Nothing
|
||||||
oldFs <- selectKeysList
|
void $ upsert f
|
||||||
[ StudyFeaturesUser ==. studyFeaturesUser
|
[ StudyFeaturesLastObserved =. now
|
||||||
, StudyFeaturesDegree ==. studyFeaturesDegree
|
, StudyFeaturesValid =. True
|
||||||
, StudyFeaturesField ==. studyFeaturesField
|
, StudyFeaturesSuperField =. studyFeaturesSuperField
|
||||||
, StudyFeaturesType ==. studyFeaturesType
|
]
|
||||||
, StudyFeaturesSemester ==. studyFeaturesSemester
|
|
||||||
]
|
|
||||||
[]
|
|
||||||
case oldFs of
|
|
||||||
[oldF] -> update oldF
|
|
||||||
[ StudyFeaturesUpdated =. now
|
|
||||||
, StudyFeaturesValid =. True
|
|
||||||
, StudyFeaturesField =. studyFeaturesField
|
|
||||||
, StudyFeaturesSuperField =. studyFeaturesSuperField
|
|
||||||
]
|
|
||||||
_other -> void $ upsert f
|
|
||||||
[ StudyFeaturesUpdated =. now
|
|
||||||
, StudyFeaturesValid =. True
|
|
||||||
, StudyFeaturesSuperField =. studyFeaturesSuperField
|
|
||||||
]
|
|
||||||
associateUserSchoolsByTerms userId
|
associateUserSchoolsByTerms userId
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|||||||
@ -24,7 +24,7 @@ parseSubTermsSemester = parse (pLMUTermsSemester <* eof) (unpack key)
|
|||||||
|
|
||||||
|
|
||||||
pStudyFeatures :: UserId -> UTCTime -> Parser [StudyFeatures]
|
pStudyFeatures :: UserId -> UTCTime -> Parser [StudyFeatures]
|
||||||
pStudyFeatures studyFeaturesUser studyFeaturesUpdated = do
|
pStudyFeatures studyFeaturesUser now = do
|
||||||
studyFeaturesDegree <- StudyDegreeKey' <$> pKey
|
studyFeaturesDegree <- StudyDegreeKey' <$> pKey
|
||||||
void $ string "$$"
|
void $ string "$$"
|
||||||
|
|
||||||
@ -41,6 +41,8 @@ pStudyFeatures studyFeaturesUser studyFeaturesUpdated = do
|
|||||||
studyFeaturesSemester <- decimal
|
studyFeaturesSemester <- decimal
|
||||||
let studyFeaturesValid = True
|
let studyFeaturesValid = True
|
||||||
studyFeaturesSuperField = Nothing
|
studyFeaturesSuperField = Nothing
|
||||||
|
studyFeaturesFirstObserved = Just now
|
||||||
|
studyFeaturesLastObserved = now
|
||||||
return StudyFeatures{..}
|
return StudyFeatures{..}
|
||||||
|
|
||||||
pStudyFeature `sepBy1` char '#'
|
pStudyFeature `sepBy1` char '#'
|
||||||
|
|||||||
@ -913,6 +913,14 @@ customMigrations = Map.fromListWith (>>)
|
|||||||
insert_ CronLastExec{ cronLastExecJob = toJSON $ JobQueueNotification NotificationAllocationUnratedApplications{..}, .. }
|
insert_ CronLastExec{ cronLastExecJob = toJSON $ JobQueueNotification NotificationAllocationUnratedApplications{..}, .. }
|
||||||
|
|
||||||
)
|
)
|
||||||
|
, ( AppliedMigrationKey [migrationVersion|39.0.0|] [version|40.0.0|]
|
||||||
|
, whenM (tableExists "study_features") $ do
|
||||||
|
[executeQQ|
|
||||||
|
ALTER TABLE study_features RENAME updated TO last_observed;
|
||||||
|
ALTER TABLE study_features ADD COLUMN first_observed timestamp with time zone;
|
||||||
|
UPDATE study_features SET first_observed = (SELECT MAX(last_observed) FROM study_features as other WHERE other."user" = study_features."user" AND other.degree = study_features.degree AND other.field = study_features.field AND other.type = study_features.type AND other.semester = study_features.semester - 1);
|
||||||
|
|]
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -44,14 +44,18 @@ $newline never
|
|||||||
<th .table__th>_{MsgStudyFeatureAge}
|
<th .table__th>_{MsgStudyFeatureAge}
|
||||||
<th .table__th>_{MsgStudyFeatureValid}
|
<th .table__th>_{MsgStudyFeatureValid}
|
||||||
<th .table__th>_{MsgStudyFeatureUpdate}
|
<th .table__th>_{MsgStudyFeatureUpdate}
|
||||||
$forall ((Entity _ StudyFeatures{studyFeaturesType, studyFeaturesSemester, studyFeaturesValid, studyFeaturesUpdated}), (Entity _ degree), (Entity _ field)) <- studies
|
$forall ((Entity _ StudyFeatures{studyFeaturesType, studyFeaturesSemester, studyFeaturesValid, studyFeaturesFirstObserved, studyFeaturesLastObserved}), (Entity _ degree), (Entity _ field)) <- studies
|
||||||
<tr .table__row>
|
<tr .table__row>
|
||||||
<td .table__td>_{field}
|
<td .table__td>_{field}
|
||||||
<td .table__td>_{degree}
|
<td .table__td>_{degree}
|
||||||
<td .table__td>_{studyFeaturesType}
|
<td .table__td>_{studyFeaturesType}
|
||||||
<td .table__td>#{studyFeaturesSemester}
|
<td .table__td>#{studyFeaturesSemester}
|
||||||
<td .table__td>#{hasTickmark studyFeaturesValid}
|
<td .table__td>#{hasTickmark studyFeaturesValid}
|
||||||
<td .table__td>^{formatTimeW SelFormatDate studyFeaturesUpdated}
|
<td .table__td>
|
||||||
|
$maybe fObs <- studyFeaturesFirstObserved
|
||||||
|
^{formatTimeRangeW SelFormatDate fObs $ Just studyFeaturesLastObserved}
|
||||||
|
$nothing
|
||||||
|
^{formatTimeW SelFormatDate studyFeaturesLastObserved}
|
||||||
$maybe _ <- mRegistration
|
$maybe _ <- mRegistration
|
||||||
<dt .deflist__dt>_{MsgCourseStudyFeature}
|
<dt .deflist__dt>_{MsgCourseStudyFeature}
|
||||||
<dd .deflist__dd>^{regFieldWidget}
|
<dd .deflist__dd>^{regFieldWidget}
|
||||||
|
|||||||
@ -43,14 +43,18 @@ $newline never
|
|||||||
<th .table__th>_{MsgStudyFeatureValid}
|
<th .table__th>_{MsgStudyFeatureValid}
|
||||||
<th .table__th>_{MsgStudyFeatureUpdate}
|
<th .table__th>_{MsgStudyFeatureUpdate}
|
||||||
|
|
||||||
$forall ((Entity _ StudyFeatures{studyFeaturesType, studyFeaturesSemester, studyFeaturesValid, studyFeaturesUpdated}), (Entity _ degree), (Entity _ field)) <- studies
|
$forall ((Entity _ StudyFeatures{studyFeaturesType, studyFeaturesSemester, studyFeaturesValid, studyFeaturesFirstObserved, studyFeaturesLastObserved}), (Entity _ degree), (Entity _ field)) <- studies
|
||||||
<tr.table__row>
|
<tr.table__row>
|
||||||
<td .table__td>_{field}
|
<td .table__td>_{field}
|
||||||
<td .table__td>_{degree}
|
<td .table__td>_{degree}
|
||||||
<td .table__td>_{studyFeaturesType}
|
<td .table__td>_{studyFeaturesType}
|
||||||
<td .table__td>#{studyFeaturesSemester}
|
<td .table__td>#{studyFeaturesSemester}
|
||||||
<td .table__td>#{hasTickmark studyFeaturesValid}
|
<td .table__td>#{hasTickmark studyFeaturesValid}
|
||||||
<td .table__td>^{formatTimeW SelFormatDateTime studyFeaturesUpdated}
|
<td .table__td>
|
||||||
|
$maybe fObs <- studyFeaturesFirstObserved
|
||||||
|
^{formatTimeRangeW SelFormatDateTime fObs $ Just studyFeaturesLastObserved}
|
||||||
|
$nothing
|
||||||
|
^{formatTimeW SelFormatDateTime studyFeaturesLastObserved}
|
||||||
<section>
|
<section>
|
||||||
<div .container>
|
<div .container>
|
||||||
$if hasRows
|
$if hasRows
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user