From f61bba8fbd7f596e503e67eac1b57945e81a709d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 30 Jul 2017 18:06:44 +0200 Subject: Clean up build somewhat --- Handler/Common.hs | 2 -- Handler/InventoryListing.hs | 4 ++-- Handler/List.hs | 5 ++--- Handler/ReferenceListing.hs | 6 +++--- Handler/Types.hs | 1 - Handler/UpdateItem.hs | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) (limited to 'Handler') diff --git a/Handler/Common.hs b/Handler/Common.hs index ab84e4e..88cbd8d 100644 --- a/Handler/Common.hs +++ b/Handler/Common.hs @@ -32,8 +32,6 @@ import Database.Persist.Sql (fromSqlKey) import qualified Web.Hashids as HID import Data.List ((\\)) -import Data.List.NonEmpty (NonEmpty) -import Data.Semigroup hiding (First(..)) import Data.Monoid (First(..)) import Data.Time.Calendar diff --git a/Handler/InventoryListing.hs b/Handler/InventoryListing.hs index d87512a..c61c62b 100644 --- a/Handler/InventoryListing.hs +++ b/Handler/InventoryListing.hs @@ -10,7 +10,7 @@ postInventoryListingR = do case insertResult of FormSuccess (Item{..} `WithType` t) -> runDB $ do - upsertBy (UniqueKind itemNormKind) (Kind itemNormKind t) [ KindType =. t ] + void $ upsertBy (UniqueKind itemNormKind) (Kind itemNormKind t) [ KindType =. t ] newItem <- insert Item{..} otherItems <- selectKeysList [ ItemNormKind ==. itemNormKind, ItemId !=. newItem ] [] when (not $ null otherItems) . addMessage "insertAmbiguous" $ @@ -42,5 +42,5 @@ putInventoryListingR :: Handler Value putInventoryListingR = do (Item{..} `WithType` t) <- requireCheckJsonBody returnJson <=< runDB $ do - upsertBy (UniqueKind itemNormKind) (Kind itemNormKind t) [ KindType =. t ] + void $ upsertBy (UniqueKind itemNormKind) (Kind itemNormKind t) [ KindType =. t ] withType =<< insertEntity Item{..} diff --git a/Handler/List.hs b/Handler/List.hs index e28bb16..522f6f5 100644 --- a/Handler/List.hs +++ b/Handler/List.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE PatternGuards #-} + module Handler.List where import Import @@ -5,14 +7,11 @@ import Import import Data.Set (Set) import qualified Data.Set as Set -import Data.Map (Map) import qualified Data.Map as Map import qualified Data.Text as Text import qualified Data.Text.Lazy as Lazy.Text -import Database.Persist.Sql (Single(..), rawSql) - import Thermoprint.Client list :: Handler (Set (WithType Text)) diff --git a/Handler/ReferenceListing.hs b/Handler/ReferenceListing.hs index 690f3f7..9fda87f 100644 --- a/Handler/ReferenceListing.hs +++ b/Handler/ReferenceListing.hs @@ -11,8 +11,8 @@ postReferenceListingR = do case insertResult of FormSuccess (Reference{..} `WithType` t) -> runDB $ do - upsertBy (UniqueKind referenceNormKind) (Kind referenceNormKind t) [ KindType =. t ] - insert Reference{..} + void $ upsertBy (UniqueKind referenceNormKind) (Kind referenceNormKind t) [ KindType =. t ] + void $ insert Reference{..} return () FormFailure errors -> mapM_ (addMessage "formError" . toHtml) errors _ -> return () @@ -30,5 +30,5 @@ putReferenceListingR :: Handler Value putReferenceListingR = do (Reference{..} `WithType` referenceType) <- requireCheckJsonBody returnJson <=< runDB $ do - upsertBy (UniqueKind referenceNormKind) (Kind referenceNormKind referenceType) [ KindType =. referenceType ] + void $ upsertBy (UniqueKind referenceNormKind) (Kind referenceNormKind referenceType) [ KindType =. referenceType ] withType =<< insertEntity Reference{..} diff --git a/Handler/Types.hs b/Handler/Types.hs index 04055ad..2fc45a3 100644 --- a/Handler/Types.hs +++ b/Handler/Types.hs @@ -2,7 +2,6 @@ module Handler.Types where import Import -import Data.Set (Set) import qualified Data.Set as Set getTypesR :: Handler Value diff --git a/Handler/UpdateItem.hs b/Handler/UpdateItem.hs index ce6b30d..ebd29e4 100644 --- a/Handler/UpdateItem.hs +++ b/Handler/UpdateItem.hs @@ -13,7 +13,7 @@ postUpdateItemR fsUpdateId = do case updateResult of FormSuccess (Item{..} `WithType` t) -> runDB $ do - upsertBy (UniqueKind itemNormKind) (Kind itemNormKind t) [ KindType =. t ] + void $ upsertBy (UniqueKind itemNormKind) (Kind itemNormKind t) [ KindType =. t ] update fsUpdateId [ ItemKind =. itemKind , ItemNormKind =. itemNormKind , ItemBought =. itemBought -- cgit v1.2.3