diff options
author | Joris | 2016-04-07 23:58:23 +0200 |
---|---|---|
committer | Joris | 2016-04-07 23:58:23 +0200 |
commit | 6541fa5316816d6f97a87a370775cfe278e7eeb8 (patch) | |
tree | 733c7136776d652db2711fad2d8427d70136bccf /src/client/elm/Model/Income.elm | |
parent | f101c20c9da59c8c644d3cb6fa0b1d08f63e40e4 (diff) |
Add cumulative incomes by user
Diffstat (limited to 'src/client/elm/Model/Income.elm')
-rw-r--r-- | src/client/elm/Model/Income.elm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/client/elm/Model/Income.elm b/src/client/elm/Model/Income.elm index f364a8b..ea990e2 100644 --- a/src/client/elm/Model/Income.elm +++ b/src/client/elm/Model/Income.elm @@ -5,6 +5,7 @@ module Model.Income , incomesDecoder , incomeIdDecoder , incomeDefinedForAll + , userCumulativeIncomeSince , cumulativeIncomesSince ) where @@ -55,6 +56,13 @@ incomeDefinedForAll userIds incomes = then head << reverse << List.sort << map .creation << catMaybes <| firstIncomes else Nothing +userCumulativeIncomeSince : Time -> Time -> Incomes -> UserId -> Int +userCumulativeIncomeSince currentTime since incomes userId = + incomes + |> Dict.values + |> List.filter (\income -> income.userId == userId) + |> cumulativeIncomesSince currentTime since + cumulativeIncomesSince : Time -> Time -> (List Income) -> Int cumulativeIncomesSince currentTime since incomes = cumulativeIncome currentTime (getOrderedIncomesSince since incomes) |