From 2a0bee58b58b469f1a35ce8168ff1caf19c85a54 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 23 Apr 2019 11:17:43 +0200 Subject: [PATCH] More idiomatic usage of `invRef` --- src/Handler/Utils/Invitations.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Handler/Utils/Invitations.hs b/src/Handler/Utils/Invitations.hs index ab73a7152..0061b730a 100644 --- a/src/Handler/Utils/Invitations.hs +++ b/src/Handler/Utils/Invitations.hs @@ -179,13 +179,13 @@ sinkInvitations InvitationConfig{..} = determineExists .| C.foldMap pure >>= lif = C.map Right | otherwise = C.mapM $ \inp@(email, fid, dat) -> - maybe (Right inp) (Left . (, dat)) <$> getKeyBy (UniqueInvitation email (toJSON $ InvRef @junction fid)) + maybe (Right inp) (Left . (, dat)) <$> getKeyBy (UniqueInvitation email (invRef @junction fid)) sinkInvitations' :: [Either (InvitationId, InvitationData junction) (UserEmail, Key (InvitationFor junction), InvitationData junction)] -> YesodJobDB UniWorX () sinkInvitations' (partitionEithers -> (existing, new)) = do when (is _Nothing (ephemeralInvitation @junction)) $ do - insertMany_ $ map (\(email, fid, dat) -> Invitation email (toJSON $ InvRef @junction fid) (toJSON $ dat ^. _invitationDBData)) new + insertMany_ $ map (\(email, fid, dat) -> Invitation email (invRef @junction fid) (toJSON $ dat ^. _invitationDBData)) new forM_ existing $ \(iid, dat) -> update iid [ InvitationData =. toJSON (dat ^. _invitationDBData) ] forM_ new $ \(jInvitee, fid, dat) -> do app <- getYesod @@ -250,7 +250,7 @@ invitationR' InvitationConfig{..} = liftHandlerT $ do Entity fid fRec <- invitationResolveFor >>= (\k -> Entity k <$> get404 k) dbData <- case ephemeralInvitation @junction of Nothing -> do - Invitation{..} <- entityVal <$> getBy404 (UniqueInvitation itEmail . toJSON $ InvRef @junction fid) + Invitation{..} <- entityVal <$> getBy404 (UniqueInvitation itEmail $ invRef @junction fid) case fromJSON invitationData of JSON.Success dbData -> return dbData JSON.Error str -> fail $ "Could not decode invitationData: " <> str @@ -275,7 +275,7 @@ invitationR' InvitationConfig{..} = liftHandlerT $ do fmap (, (dataWidget, dataEnctype), heading, explanation) . formResultMaybe dataRes $ \case Nothing -> do addMessageI Info MsgInvitationDeclined - deleteBy . UniqueInvitation itEmail . toJSON $ InvRef @junction fid + deleteBy . UniqueInvitation itEmail $ invRef @junction fid return . Just $ SomeRoute HomeR Just jData -> do mResult <- insertUniqueEntity $ review _InvitableJunction (invitee, fid, jData)