Apply 2 suggestion(s) to 2 file(s)
This commit is contained in:
parent
ca3d2713e6
commit
89e7345b8c
@ -92,7 +92,7 @@ storedFavouriteReason tid ssh csh muid = fmap unValueFirst . E.select . E.from $
|
||||
where
|
||||
unValueFirst :: [(E.Value (Maybe a), E.Value Bool)] -> Maybe (Maybe a, Bool)
|
||||
-- `over each E.unValue` doesn't work here, since E.unValue is monomorphised
|
||||
unValueFirst = fmap (over _1 E.unValue . over _2 E.unValue) . listToMaybe
|
||||
unValueFirst = fmap (bimap E.unValue E.unValue) . listToMaybe
|
||||
|
||||
|
||||
data MemcachedKeyFavourites
|
||||
|
||||
@ -38,12 +38,7 @@ postCFavouriteR :: TermId -> SchoolId -> CourseShorthand -> Handler ()
|
||||
postCFavouriteR tid ssh csh = void $ do
|
||||
muid <- maybeAuthPair
|
||||
runDB $ void $ do
|
||||
mcid <- fmap (fmap E.unValue . listToMaybe) . E.select . E.from $ \course -> do
|
||||
E.where_ $ course E.^. CourseTerm E.==. E.val tid
|
||||
E.&&. course E.^. CourseSchool E.==. E.val ssh
|
||||
E.&&. course E.^. CourseShorthand E.==. E.val csh
|
||||
E.limit 1 -- we know that there is at most one match, but we tell the DB this info too
|
||||
pure $ course E.^. CourseId
|
||||
mcid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
|
||||
if | Just cid <- mcid, Just uid <- view _1 <$> muid -> do
|
||||
now <- liftIO getCurrentTime
|
||||
-- Nothing means blacklist
|
||||
|
||||
Loading…
Reference in New Issue
Block a user