let the function get the time itself

This commit is contained in:
nek0 2019-08-09 20:55:40 +02:00
parent 573d2af0df
commit 5280255ddc
2 changed files with 18 additions and 18 deletions

View file

@ -184,9 +184,8 @@ userList muid ref = do
productNew :: Maybe Int -> ProductSubmit -> MateHandler Int productNew :: Maybe Int -> ProductSubmit -> MateHandler Int
productNew (Just _) bevsub = do productNew (Just _) bevsub = do
conn <- rsConnection <$> ask conn <- rsConnection <$> ask
now <- liftIO $ getCurrentTime
bevid <- insertProduct bevsub conn bevid <- insertProduct bevsub conn
void $ insertNewEmptyAmount bevid now bevsub conn void $ insertNewEmptyAmount bevid bevsub conn
return bevid return bevid
productNew Nothing _ = productNew Nothing _ =
throwError $ err403 throwError $ err403

View file

@ -56,25 +56,26 @@ amountTable = table "amount" (
insertNewEmptyAmount insertNewEmptyAmount
:: Int -- | the associated product id :: Int -- | the associated product id
-> UTCTime -- | current time
-> ProductSubmit -- | submitted product data -> ProductSubmit -- | submitted product data
-> PGS.Connection -> PGS.Connection
-> MateHandler Int -> MateHandler Int
insertNewEmptyAmount bevid now (ProductSubmit _ price _ _ _ _ _ _ _) conn = insertNewEmptyAmount bevid (ProductSubmit _ price _ _ _ _ _ _ _) conn =
fmap head $ liftIO $ runInsert_ conn $ Insert liftIO $ do
{ iTable = amountTable now <- getCurrentTime
, iRows = fmap head $ runInsert_ conn $ Insert
[ { iTable = amountTable
( C.constant bevid , iRows =
, C.constant now [
, C.constant (0 :: Int) ( C.constant bevid
, C.constant price , C.constant now
, C.constant False , C.constant (0 :: Int)
) , C.constant price
] , C.constant False
, iReturning = rReturning (\(id_, _, _, _, _) -> id_) )
, iOnConflict = Nothing ]
} , iReturning = rReturning (\(id_, _, _, _, _) -> id_)
, iOnConflict = Nothing
}
getLatestPriceByProductId getLatestPriceByProductId
:: Int -- The associated Product ID :: Int -- The associated Product ID