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
|
where
|
||||||
unValueFirst :: [(E.Value (Maybe a), E.Value Bool)] -> Maybe (Maybe a, Bool)
|
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
|
-- `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
|
data MemcachedKeyFavourites
|
||||||
|
|||||||
@ -38,12 +38,7 @@ postCFavouriteR :: TermId -> SchoolId -> CourseShorthand -> Handler ()
|
|||||||
postCFavouriteR tid ssh csh = void $ do
|
postCFavouriteR tid ssh csh = void $ do
|
||||||
muid <- maybeAuthPair
|
muid <- maybeAuthPair
|
||||||
runDB $ void $ do
|
runDB $ void $ do
|
||||||
mcid <- fmap (fmap E.unValue . listToMaybe) . E.select . E.from $ \course -> do
|
mcid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
|
||||||
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
|
|
||||||
if | Just cid <- mcid, Just uid <- view _1 <$> muid -> do
|
if | Just cid <- mcid, Just uid <- view _1 <$> muid -> do
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
-- Nothing means blacklist
|
-- Nothing means blacklist
|
||||||
|
|||||||
Reference in New Issue
Block a user