limit the returned rows
This commit is contained in:
parent
9f78818687
commit
61b094e3e6
1 changed files with 5 additions and 5 deletions
|
@ -83,7 +83,7 @@ getLatestPriceByProductId
|
||||||
-> MateHandler Int -- The price in cents
|
-> MateHandler Int -- The price in cents
|
||||||
getLatestPriceByProductId pid conn = do
|
getLatestPriceByProductId pid conn = do
|
||||||
amounts <- liftIO $ runSelect conn $
|
amounts <- liftIO $ runSelect conn $
|
||||||
orderBy (desc (\(_, ts, _, _, _) -> ts))
|
limit 1 $ orderBy (desc (\(_, ts, _, _, _) -> ts))
|
||||||
(keepWhen (\(id_, _, _, _, _) -> id_ .== C.constant pid) <<< queryTable amountTable)
|
(keepWhen (\(id_, _, _, _, _) -> id_ .== C.constant pid) <<< queryTable amountTable)
|
||||||
:: MateHandler
|
:: MateHandler
|
||||||
[ ( Int
|
[ ( Int
|
||||||
|
@ -103,7 +103,7 @@ getLatestAmountByProductId
|
||||||
-> MateHandler Int -- The amount
|
-> MateHandler Int -- The amount
|
||||||
getLatestAmountByProductId pid conn = do
|
getLatestAmountByProductId pid conn = do
|
||||||
amounts <- liftIO $ runSelect conn $
|
amounts <- liftIO $ runSelect conn $
|
||||||
orderBy (desc (\(_, ts, _, _, _) -> ts))
|
limit 1 $ orderBy (desc (\(_, ts, _, _, _) -> ts))
|
||||||
(keepWhen (\(id_, _, _, _, _) -> id_ .== C.constant pid) <<< queryTable amountTable)
|
(keepWhen (\(id_, _, _, _, _) -> id_ .== C.constant pid) <<< queryTable amountTable)
|
||||||
:: MateHandler
|
:: MateHandler
|
||||||
[ ( Int
|
[ ( Int
|
||||||
|
@ -124,7 +124,7 @@ getLatestTotalPrice
|
||||||
-> MateHandler Int -- The price in cents
|
-> MateHandler Int -- The price in cents
|
||||||
getLatestTotalPrice (PurchaseDetail pid amount) conn = do
|
getLatestTotalPrice (PurchaseDetail pid amount) conn = do
|
||||||
amounts <- liftIO $ runSelect conn $
|
amounts <- liftIO $ runSelect conn $
|
||||||
orderBy (desc (\(_, ts, _, _, _) -> ts)) $
|
limit 1 $ orderBy (desc (\(_, ts, _, _, _) -> ts)) $
|
||||||
keepWhen (\(id_, _, _, _, _) -> id_ .== C.constant pid) <<<
|
keepWhen (\(id_, _, _, _, _) -> id_ .== C.constant pid) <<<
|
||||||
queryTable amountTable
|
queryTable amountTable
|
||||||
:: MateHandler
|
:: MateHandler
|
||||||
|
@ -146,7 +146,7 @@ checkProductAvailability
|
||||||
-> MateHandler (Maybe Int) -- | Returns maybe missing amount
|
-> MateHandler (Maybe Int) -- | Returns maybe missing amount
|
||||||
checkProductAvailability (PurchaseDetail pid amount) conn = do
|
checkProductAvailability (PurchaseDetail pid amount) conn = do
|
||||||
realamount <- (\(_, _, ramount, _, _) -> ramount) <$> head <$>
|
realamount <- (\(_, _, ramount, _, _) -> ramount) <$> head <$>
|
||||||
(liftIO $ runSelect conn $
|
(liftIO $ runSelect conn $ limit 1 $
|
||||||
orderBy (desc (\(_, ts, _, _, _) -> ts)) $
|
orderBy (desc (\(_, ts, _, _, _) -> ts)) $
|
||||||
keepWhen (\(id_, _, _, _, _) -> id_ .== C.constant pid) <<<
|
keepWhen (\(id_, _, _, _, _) -> id_ .== C.constant pid) <<<
|
||||||
queryTable amountTable
|
queryTable amountTable
|
||||||
|
@ -230,7 +230,7 @@ postBuyProductAmountUpdate
|
||||||
postBuyProductAmountUpdate (PurchaseDetail pid pdamount) conn = do
|
postBuyProductAmountUpdate (PurchaseDetail pid pdamount) conn = do
|
||||||
now <- liftIO $ getCurrentTime
|
now <- liftIO $ getCurrentTime
|
||||||
(amount, oldprice) <- (\(_, _, am, op, _) -> (am, op)) <$> head <$> (
|
(amount, oldprice) <- (\(_, _, am, op, _) -> (am, op)) <$> head <$> (
|
||||||
liftIO $ runSelect conn $
|
liftIO $ runSelect conn $ limit 1 $
|
||||||
orderBy (desc (\(_, ts, _, _, _) -> ts)) $
|
orderBy (desc (\(_, ts, _, _, _) -> ts)) $
|
||||||
keepWhen (\(id_, _, _, _, _) -> id_ .== C.constant pid) <<<
|
keepWhen (\(id_, _, _, _, _) -> id_ .== C.constant pid) <<<
|
||||||
queryTable amountTable
|
queryTable amountTable
|
||||||
|
|
Loading…
Reference in a new issue