diff --git a/src/Foundation/SiteLayout.hs b/src/Foundation/SiteLayout.hs index a5dd80bee..063894fa0 100644 --- a/src/Foundation/SiteLayout.hs +++ b/src/Foundation/SiteLayout.hs @@ -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 diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index f4cd36c77..a23709849 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -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