diff options
author | Joris | 2016-03-27 17:36:33 +0200 |
---|---|---|
committer | Joris | 2016-03-27 17:59:32 +0200 |
commit | 869bab77e93e2a6c776a4b1fc35ef0fd5df22f5f (patch) | |
tree | 917a9e871eff1c487da63ea2407234d7e3829dda /src/server/Model/Income.hs | |
parent | a8882071da12cbb5b0bf2f003322e42e181b0c82 (diff) |
Compute payers client side rather than server side
Diffstat (limited to 'src/server/Model/Income.hs')
-rw-r--r-- | src/server/Model/Income.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/server/Model/Income.hs b/src/server/Model/Income.hs index 70b9149..2177617 100644 --- a/src/server/Model/Income.hs +++ b/src/server/Model/Income.hs @@ -1,5 +1,5 @@ module Model.Income - ( getIncome + ( getJsonIncome , getFirstIncome , getIncomes , setIncome @@ -12,13 +12,15 @@ import Control.Monad.IO.Class (liftIO) import Database.Persist import Model.Database +import qualified Model.Json.Income as Json -getIncome :: UserId -> Persist (Maybe Income) -getIncome userId = - fmap entityVal <$> selectFirst [IncomeUserId ==. userId] [Desc IncomeCreation] +getJsonIncome :: Entity Income -> Json.Income +getJsonIncome incomeEntity = + Json.Income (entityKey incomeEntity) (incomeUserId income) (incomeCreation income) (incomeAmount income) + where income = entityVal incomeEntity -getIncomes :: Persist [Income] -getIncomes = map entityVal <$> selectList [] [] +getIncomes :: Persist [Entity Income] +getIncomes = selectList [] [] getFirstIncome :: UserId -> Persist (Maybe Income) getFirstIncome userId = |