fucking shit
This commit is contained in:
parent
cb3e7019d4
commit
b6e3e5b487
1 changed files with 6 additions and 9 deletions
|
@ -58,12 +58,9 @@ getStatisticsR = do
|
||||||
archangels <- runDB $ selectList [UserBalance >. 5000] []
|
archangels <- runDB $ selectList [UserBalance >. 5000] []
|
||||||
archdevils <- runDB $ selectList [UserBalance <. -5000] []
|
archdevils <- runDB $ selectList [UserBalance <. -5000] []
|
||||||
bevs <- runDB $ selectList [] [Asc BeverageId]
|
bevs <- runDB $ selectList [] [Asc BeverageId]
|
||||||
totalLossPrime <- return $ foldl (\acc (Entity _ bev) ->
|
-- let totalLossPrime = foldl (\acc (Entity _ bev) -> let primePrice = (fromIntegral $ fromMaybe 0 (beveragePricePerCrate bev)) / (fromIntegral $ fromMaybe 1 (beveragePerCrate bev)) in acc + (((fromIntegral $ abs $ beverageCorrectedAmount bev) * primePrice) / 100)) 0 bevs
|
||||||
let primePrice = (fromIntegral $ fromMaybe 0 (beveragePricePerCrate bev)) / (fromIntegral $ fromMaybe 1 (beveragePerCrate bev))
|
|
||||||
in acc + (((fromIntegral $ beverageCorrectedAmount bev) * primePrice) / 100)
|
|
||||||
) 0 bevs
|
|
||||||
totalLossRetail <- return $ foldl (\acc (Entity _ bev) ->
|
totalLossRetail <- return $ foldl (\acc (Entity _ bev) ->
|
||||||
acc + ((fromIntegral $ beverageCorrectedAmount bev) * (fromIntegral $ beveragePrice bev) / 100)
|
acc + ((fromIntegral $ abs $ beverageCorrectedAmount bev) * (fromIntegral $ beveragePrice bev) / 100)
|
||||||
) 0 bevs
|
) 0 bevs
|
||||||
return $ repJson $ toJSON $ Statistics
|
return $ repJson $ toJSON $ Statistics
|
||||||
(length users)
|
(length users)
|
||||||
|
@ -82,7 +79,7 @@ getStatisticsR = do
|
||||||
aNegativeBalance
|
aNegativeBalance
|
||||||
dPositiveBalance
|
dPositiveBalance
|
||||||
dNegativeBalance
|
dNegativeBalance
|
||||||
totalLossPrime
|
-- totalLossPrime
|
||||||
totalLossRetail
|
totalLossRetail
|
||||||
|
|
||||||
data Statistics = Statistics
|
data Statistics = Statistics
|
||||||
|
@ -102,12 +99,12 @@ data Statistics = Statistics
|
||||||
, activeUsersNegativeBalance :: Double
|
, activeUsersNegativeBalance :: Double
|
||||||
, deadUsersPositiveBalance :: Double
|
, deadUsersPositiveBalance :: Double
|
||||||
, deadUsersNegativeBalance :: Double
|
, deadUsersNegativeBalance :: Double
|
||||||
, totalLossPrime :: Double
|
-- , totalLossPrime :: Double
|
||||||
, totalLossRetail :: Double
|
, totalLossRetail :: Double
|
||||||
}
|
}
|
||||||
|
|
||||||
instance ToJSON Statistics where
|
instance ToJSON Statistics where
|
||||||
toJSON (Statistics tu au du pb nb tb gu eu na nd aa ad aupb aunb dupb dunb tlp tlr) =
|
toJSON (Statistics tu au du pb nb tb gu eu na nd aa ad aupb aunb dupb dunb tlr) =
|
||||||
object
|
object
|
||||||
[ "total_users" .= tu
|
[ "total_users" .= tu
|
||||||
, "active_users" .= au
|
, "active_users" .= au
|
||||||
|
@ -125,6 +122,6 @@ instance ToJSON Statistics where
|
||||||
, "active_users_negative_balance" .= aunb
|
, "active_users_negative_balance" .= aunb
|
||||||
, "inactive_users_positive_balance" .= dupb
|
, "inactive_users_positive_balance" .= dupb
|
||||||
, "inactive_users_negative_balance" .= dunb
|
, "inactive_users_negative_balance" .= dunb
|
||||||
, "total_loss_prime_price" .= tlp
|
-- , "total_loss_prime_price" .= tlp
|
||||||
, "total_loss_retail_price" .= tlr
|
, "total_loss_retail_price" .= tlr
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue