chore(lms): table filter finally typing

This commit is contained in:
Steffen Jost 2022-02-16 18:13:52 +01:00
parent 3656f1e6f1
commit e338c025e5
3 changed files with 12 additions and 9 deletions

View File

@ -86,7 +86,7 @@ LmsUser
pin Text pin Text
resetPin Bool default=false -- should pin be reset? resetPin Bool default=false -- should pin be reset?
success Bool Maybe -- open, success or failure; isJust indicates user will be deleted from LMS success Bool Maybe -- open, success or failure; isJust indicates user will be deleted from LMS
-- success LmsNotification --this would also encode Day information?! -- success LmsStatus --this would also encode Day information?!
started UTCTime default=now() started UTCTime default=now()
received UTCTime Maybe -- last acknowledgement by LMS received UTCTime Maybe -- last acknowledgement by LMS
ended UTCTime Maybe -- ident was deleted from LMS ended UTCTime Maybe -- ident was deleted from LMS
@ -113,7 +113,7 @@ LmsResult
LmsAudit LmsAudit
qualification QualificationId qualification QualificationId
ident LmsIdent ident LmsIdent
notificationType LmsNotification notificationType LmsStatus
received UTCTime -- timestamp from LmsUserlist/LmsResult received UTCTime -- timestamp from LmsUserlist/LmsResult
processed UTCTime default=now() processed UTCTime default=now()
deriving Generic deriving Generic

View File

@ -129,11 +129,12 @@ mkResultTable qid = do
] -- TODO: add more columns for manual debugging view !!! ] -- TODO: add more columns for manual debugging view !!!
dbtSorting = Map.fromList dbtSorting = Map.fromList
[ ("ident" , SortColumn $ queryLmsResult >>> (E.^. LmsResultIdent)) [ ("ident" , SortColumn $ queryLmsResult >>> (E.^. LmsResultIdent))
, ("success", SortColumn $ queryLmsResult >>> (E.^. LmsResultSuccess)) -- , ("success", SortColumn $ queryLmsResult >>> (E.^. LmsResultSuccess))
-- , ("success", SortColumn . views queryLmsResult (E.^. LmsResultSuccess)) , ("success", SortColumn $ views (to queryLmsResult) (E.^. LmsResultSuccess))
] ]
dbtFilter = Map.fromList dbtFilter = Map.fromList
[ -- ("ident" , FilterColumn $ queryLmsResult >>> (E.^. LmsResultIdent)) [ -- singletonMap "ident" . FilterColumn . E.mkContainsFilter $ views (to queryLmsResult) (E.^. LmsResultIdent)
("ident", FilterColumn . E.mkContainsFilter $ views (to queryLmsResult) (E.^. LmsResultIdent))
] ]
dbtFilterUI = const mempty -- TODO !!! continue here !!! Manual filtering useful to deal with user complaints! dbtFilterUI = const mempty -- TODO !!! continue here !!! Manual filtering useful to deal with user complaints!
dbtStyle = def dbtStyle = def

View File

@ -9,17 +9,19 @@ module Model.Types.Lms
import Import.NoModel import Import.NoModel
import Database.Persist.Sql import Database.Persist.Sql
import qualified Database.Esqueleto.Legacy as E
import qualified Data.Csv as Csv import qualified Data.Csv as Csv
import Utils.Lens.TH import Utils.Lens.TH
newtype LmsIdent = LmsIdent { getLmsIdent :: Text } newtype LmsIdent = LmsIdent { getLmsIdent :: Text }
deriving (Eq, Ord, Read, Show, Generic, Typeable) deriving (Eq, Ord, Read, Show, Generic, Typeable)
deriving newtype (NFData, PersistField, PersistFieldSql, Csv.ToField, Csv.FromField) deriving newtype (NFData, PathPiece, PersistField, PersistFieldSql, Csv.ToField, Csv.FromField)
instance E.SqlString LmsIdent where
makeLenses_ ''LmsIdent makeLenses_ ''LmsIdent
-- TODO: is this a good idea? Maybe just an ordinary Enum and a separate Day Column in the DB would be better, especially since LmsBlocked should really also encode a Day -- TODO: is this a good idea? Maybe just an ordinary Enum and a separate Day Column in the DB would be better, especially since LmsBlocked should really also encode a Day
data LmsNotification = LmsOpen | LmsBlocked | LmsSuccess Day data LmsStatus = LmsOpen | LmsBlocked | LmsSuccess Day
deriving (Eq, Ord, Read, Show, Generic, Typeable, NFData) deriving (Eq, Ord, Read, Show, Generic, Typeable, NFData)
deriveJSON defaultOptions deriveJSON defaultOptions
@ -27,5 +29,5 @@ deriveJSON defaultOptions
, fieldLabelModifier = camelToPathPiece' 1 , fieldLabelModifier = camelToPathPiece' 1
, omitNothingFields = True , omitNothingFields = True
, sumEncoding = TaggedObject "lmsaudit" "lmsaction" , sumEncoding = TaggedObject "lmsaudit" "lmsaction"
} ''LmsNotification } ''LmsStatus
derivePersistFieldJSON ''LmsNotification derivePersistFieldJSON ''LmsStatus