diff --git a/src/Foundation/Yesod/Middleware.hs b/src/Foundation/Yesod/Middleware.hs index 95d3629f0..683bb8ab6 100644 --- a/src/Foundation/Yesod/Middleware.hs +++ b/src/Foundation/Yesod/Middleware.hs @@ -184,11 +184,9 @@ updateFavourites cData = void . withReaderT projectBackend . runMaybeT $ do mcid <- (for cData $ \(tid, ssh, csh) -> MaybeT . getKeyBy $ TermSchoolCourseShort tid ssh csh) :: MaybeT (SqlPersistT m) (Maybe CourseId) User{userMaxFavourites} <- MaybeT $ get uid - -- TODO optimize for `userMaxFavourites == 0` - -- no need to store (upsert?) them, since they will be removed in the pruning step anyway! - -- update Favourites - for_ mcid $ \cid -> + -- no need to store them with userMaxFavourites==0, since they will be removed in the pruning step anyway! + when (userMaxFavourites > 0) $ for_ mcid $ \cid -> void . lift $ upsertBy (UniqueCourseFavourite uid cid) (CourseFavourite uid cid FavouriteVisited now)