From 6541fa5316816d6f97a87a370775cfe278e7eeb8 Mon Sep 17 00:00:00 2001 From: Joris Date: Thu, 7 Apr 2016 23:58:23 +0200 Subject: Add cumulative incomes by user --- src/client/elm/Model/Income.elm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/client/elm/Model/Income.elm') 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) -- cgit v1.2.3