From 89e7345b8c814417176254e23d5ff0eb09239649 Mon Sep 17 00:00:00 2001 From: Wolfgang Witt Date: Tue, 13 Apr 2021 10:40:14 +0000 Subject: [PATCH] Apply 2 suggestion(s) to 2 file(s) --- src/Foundation/SiteLayout.hs | 2 +- src/Handler/Course.hs | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) 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