let the function get the time itself
This commit is contained in:
parent
6fa47c0e1e
commit
9f78818687
2 changed files with 18 additions and 18 deletions
|
@ -181,9 +181,8 @@ userList muid ref = do
|
|||
productNew :: Maybe Int -> ProductSubmit -> MateHandler Int
|
||||
productNew (Just _) bevsub = do
|
||||
conn <- rsConnection <$> ask
|
||||
now <- liftIO $ getCurrentTime
|
||||
bevid <- insertProduct bevsub conn
|
||||
void $ insertNewEmptyAmount bevid now bevsub conn
|
||||
void $ insertNewEmptyAmount bevid bevsub conn
|
||||
return bevid
|
||||
productNew Nothing _ =
|
||||
throwError $ err403
|
||||
|
|
|
@ -56,25 +56,26 @@ amountTable = table "amount" (
|
|||
|
||||
insertNewEmptyAmount
|
||||
:: Int -- | the associated product id
|
||||
-> UTCTime -- | current time
|
||||
-> ProductSubmit -- | submitted product data
|
||||
-> PGS.Connection
|
||||
-> MateHandler Int
|
||||
insertNewEmptyAmount bevid now (ProductSubmit _ price _ _ _ _ _ _ _) conn =
|
||||
fmap head $ liftIO $ runInsert_ conn $ Insert
|
||||
{ iTable = amountTable
|
||||
, iRows =
|
||||
[
|
||||
( C.constant bevid
|
||||
, C.constant now
|
||||
, C.constant (0 :: Int)
|
||||
, C.constant price
|
||||
, C.constant False
|
||||
)
|
||||
]
|
||||
, iReturning = rReturning (\(id_, _, _, _, _) -> id_)
|
||||
, iOnConflict = Nothing
|
||||
}
|
||||
insertNewEmptyAmount bevid (ProductSubmit _ price _ _ _ _ _ _ _) conn =
|
||||
liftIO $ do
|
||||
now <- getCurrentTime
|
||||
fmap head $ runInsert_ conn $ Insert
|
||||
{ iTable = amountTable
|
||||
, iRows =
|
||||
[
|
||||
( C.constant bevid
|
||||
, C.constant now
|
||||
, C.constant (0 :: Int)
|
||||
, C.constant price
|
||||
, C.constant False
|
||||
)
|
||||
]
|
||||
, iReturning = rReturning (\(id_, _, _, _, _) -> id_)
|
||||
, iOnConflict = Nothing
|
||||
}
|
||||
|
||||
getLatestPriceByProductId
|
||||
:: Int -- The associated Product ID
|
||||
|
|
Loading…
Reference in a new issue