chore(day): attempt to fix participant note suggestions
This commit is contained in:
parent
500c9a749a
commit
564488d5fa
@ -296,17 +296,24 @@ colParticipantNoteField = sortable (Just "note-tutorial") (i18nCell MsgTutorialN
|
||||
mopt (textField & cfStrip & addDatalist (suggsParticipantNote cid tid)) (fsUniq mkUnique "note-tutorial") (Just note)
|
||||
)
|
||||
|
||||
-- deriving instance (Generic a) => Generic (OptionList a)
|
||||
-- deriving instance (Binary a, Generic a) => Binary (OptionList a)
|
||||
-- deriving instance Generic (OptionList Text)
|
||||
-- deriving instance Binary (OptionList Text)
|
||||
deriving instance Generic (Option Text)
|
||||
deriving instance Binary (Option Text)
|
||||
|
||||
suggsParticipantNote :: CourseId -> TutorialId -> Handler (OptionList Text)
|
||||
suggsParticipantNote cid tid = memcachedByHere (Just . Right $ 12 * diffSecond) (cid,tid) $ do -- TODO: better memcached key
|
||||
let qry = do
|
||||
(prio, tpn) <- E.from $ TutorialParticipant
|
||||
suggsParticipantNote cid tid = $(memcachedByHere) (Just . Right $ 12 * diffSecond) (cid,tid) $ runDB $ do -- TODO: better memcached key
|
||||
let qry :: E.SqlQuery (E.SqlExpr (E.Value Text)) = do
|
||||
(prio, tpn) <- E.from $
|
||||
( do
|
||||
tpa <- E.from $ E.table @TutorialParticipant
|
||||
E.distinct $ pure ()
|
||||
E.where_ $ E.isJust (tpa E.^. TutorialParticipantNote)
|
||||
E.&&. tpa E.^. TutorialParticipantTutorial E.==. E.val tid
|
||||
E.limit maxSuggestions
|
||||
pure (E.val 1, tpa E.^. TutorialParticipantNote)
|
||||
pure (E.val (1 :: Int64), tpa E.^. TutorialParticipantNote)
|
||||
) `E.unionAll_`
|
||||
( do
|
||||
(tpa :& tut) <- E.from $ E.table @TutorialParticipant
|
||||
@ -328,8 +335,8 @@ suggsParticipantNote cid tid = memcachedByHere (Just . Right $ 12 * diffSecond)
|
||||
)
|
||||
E.orderBy [E.asc prio, E.asc tpn]
|
||||
E.limit maxSuggestions
|
||||
pure tpn
|
||||
mkOptionsE qry E.unValue (text2message . E.unValue) (toPathPiece . E.unValue)
|
||||
pure $ E.coalesceDefault [tpn] $ E.val ""
|
||||
mkOptionsE qry (pure . E.unValue) (pure . text2message . E.unValue) (pure . toPathPiece . E.unValue)
|
||||
|
||||
|
||||
suggsAttentionNote :: Handler (OptionList Textarea)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user