Fix logged hours display error.

[?]
Jan 31, 2021, 11:18 PM
W3PIWHDK4DQHBD54FN4PIF3PELIT2V74L62AMMXM2M5BHYAACALAC

Dependencies

  • [2] DZ7G36NC Allow first-revenue cutoff for depreciation.
  • [3] M4PWY5RU Preliminary work to add support for Zcash payments.
  • [4] HMDM3B55 Implement core of payments/billing infrastructure.
  • [5] IR75ZMX3 Return actual events for interval ends, not just timestamps.
  • [6] NVOCQVAS Initial failing tests.
  • [7] Y35QCWYW Minor improvement in WorkIndex type to eliminate duplicated information.
  • [8] NEDDHXUK Reformat via stylish-haskell
  • [9] A2J7B4SC Initial impl of depreciation function.
  • [10] CI4OPKQM Add payouts spec.
  • [11] SCXG6TJW Make log reduction safer in presence of overlapping events.
  • [12] 4R7XIYK3 Switch from ClassyPrelude to Relude
  • [13] 4SCFOJGN Specs for recovering intervals from the log now pass.
  • [14] 7HPY3QPF Fix linting errors. (yay hlint!)
  • [15] EMVTF2IW WIP moving back to snap.
  • [16] KNSI575V Cleanup of EventLog types.
  • [17] RKY3XCSI Get the correct contributor data.
  • [18] OBFPJS2G Project successfully builds and tests under nix.
  • [19] LTSVBVA2 Update to a recent haskoin-core. Fix Stack build.
  • [20] N4NDAZYT Initial implementation of payouts.
  • [21] OV5AKJHA Remove unused LogInterval type.
  • [22] B6HWAPDP Modularize & update to recent haskoin.
  • [23] 7KZP4RHZ Switch from Data.Time to Data.Thyme
  • [24] 4U7F3CPI THE GREAT RENAMING OF THINGS!
  • [25] U7YAT2ZK Add error reporting to signup form.
  • [26] 64C6AWH6 Rename Ananke -> Quixotic, project reboot.
  • [27] EFSXYZPO Autoformat everything with brittany.
  • [28] UUR6SMCA Add start of specs for auctions.
  • [29] 5DRIWGLU Improving TimeLog specs
  • [30] UWMGUJOW Autoformat sources.
  • [31] X3ES7NUA Fine. I'll use ormolu. At least it doesn't break the code.
  • [32] 4354Y4PE Add endpoint to list project contributors.
  • [33] NMWWP4ZN Trying out Hspec
  • [*] QMRKFEPG Refactor QDB to use a free monad algebra instead.
  • [*] IPG33FAW Add billing daemon
  • [*] PBD7LZYQ Postgres & auth are beginning to function.

Change contents

  • edit in lib/Aftok/TimeLog.hs at line 2
    [3.50375][3.50375:50408](),[3.50408][3.18997:19027]()
    {-# LANGUAGE TemplateHaskell #-}
    {-# LANGUAGE ViewPatterns #-}
  • edit in lib/Aftok/TimeLog.hs at line 3
    [3.260]
    [3.260]
    {-# LANGUAGE TemplateHaskell #-}
  • edit in lib/Aftok/TimeLog.hs at line 5
    [3.298]
    [3.883]
    {-# LANGUAGE ViewPatterns #-}
  • replacement in lib/Aftok/TimeLog.hs at line 24
    [3.22423][3.299:381]()
    import Control.Lens (Lens', (.~), (^.), makeClassy, makeLenses, makePrisms, view)
    [3.22423]
    [3.51047]
    import Control.Lens ((.~), Lens', (^.), makeClassy, makeLenses, makePrisms, view)
  • edit in lib/Aftok/TimeLog.hs at line 49
    [3.19329]
    [3.586]
  • edit in lib/Aftok/TimeLog.hs at line 87
    [3.674][3.674:675]()
  • edit in lib/Aftok/TimeLog.hs at line 174
    [2.1688]
    [2.1688]
  • replacement in lib/Aftok/TimeLog.hs at line 179
    [3.979][3.23134:23164](),[3.23134][3.23134:23164](),[3.23164][2.1694:1793]()
    workCredit depf ptime ivals =
    let intervalCredit ival = (Sum . ilen &&& Sum . depf Nothing ptime) $ fmap (view eventTime) ival
    [3.979]
    [2.1793]
    workCredit depf payoutDate ivals =
    let intervalCredit ival = (Sum . ilen &&& Sum . depf Nothing payoutDate) $ fmap (view eventTime) ival
  • replacement in lib/Aftok/TimeLog.hs at line 188
    [3.1172][3.4834:4871](),[3.19859][3.4834:4871](),[3.23365][3.4834:4871](),[3.32156][3.4834:4871](),[3.90816][3.4834:4871](),[3.1819][3.4834:4871]()
    payouts dep ptime (WorkIndex widx) =
    [3.1172]
    [3.23366]
    payouts depf payoutDate (WorkIndex widx) =
  • replacement in lib/Aftok/TimeLog.hs at line 191
    [3.12354][3.23454:23517]()
    let (logged, depreciated) = workCredit dep ptime ivals
    [3.12354]
    [3.23517]
    let (logged, depreciated) = workCredit depf payoutDate ivals
  • replacement in lib/Aftok/TimeLog.hs at line 240
    [3.20872][3.20872:21155]()
    (StartWork t, StopWork t') | t' > t -> Right $ Interval e e' -- complete interval found
    (StartWork t, StartWork t') -> Left $ if t > t' then e else e' -- ignore redundant starts
    (StopWork t, StopWork t') -> Left $ if t <= t' then e else e' -- ignore redundant ends
    [3.20872]
    [3.21155]
    (StartWork t, StopWork t')
    | t' > t ->
    -- complete interval found
    Right $ Interval e e'
    (StartWork t, StartWork t') ->
    -- ignore redundant starts
    Left $ if t > t' then e else e'
    (StopWork t, StopWork t') ->
    -- ignore redundant ends
    Left $ if t <= t' then e else e'
  • edit in lib/Aftok/Util.hs at line 10
    [3.55645]
    [35.10199]
    import qualified Debug.Trace as T
  • edit in lib/Aftok/Util.hs at line 32
    [36.31166]
    traceWith :: Show b => (a -> b) -> a -> a
    traceWith f a = T.trace (show $ f a) a
  • replacement in server/Aftok/Snaplet/Projects.hs at line 125
    [3.26177][3.26177:26269]()
    _timeDevoted = Hours . (`div` 360) . round . C.toSeconds' $ ws ^. wsLogged,
    [3.26177]
    [3.26269]
    _timeDevoted = Hours . (`div` 3600) . round . C.toSeconds' $ ws ^. wsLogged,
  • edit in test/Aftok/TimeLogSpec.hs at line 2
    [3.82682][3.1252:1286]()
    {-# LANGUAGE TypeApplications #-}
  • edit in test/Aftok/TimeLogSpec.hs at line 3
    [3.12134]
    [3.3106]
    {-# LANGUAGE TypeApplications #-}
  • edit in test/Aftok/TimeLogSpec.hs at line 12
    [3.1660][3.1287:1322]()
    import Prelude hiding (head, tail)
  • replacement in test/Aftok/TimeLogSpec.hs at line 15
    [3.82762][3.1323:1419](),[3.1419][2.1856:1965](),[2.1965][3.1420:1449](),[3.82813][3.1420:1449]()
    import Aftok.Types (UserId (..), DepreciationFunction(..))
    import Control.Lens ((^.), view, to)
    import Data.AffineSpace ((.-.), (.+^))
    import Data.VectorSpace ((*^), Sum (..), (^+^), (^-^), getSum, zeroV)
    import Data.Maybe (fromJust)
    [3.82762]
    [3.1449]
    import Aftok.Types (DepreciationFunction (..), UserId (..))
    import Control.Lens ((^.), to, view)
    import Data.AffineSpace ((.+^))
  • edit in test/Aftok/TimeLogSpec.hs at line 19
    [3.1479][3.1479:1503]()
    import Data.Ratio ((%))
  • edit in test/Aftok/TimeLogSpec.hs at line 21
    [3.82892]
    [2.1966]
    import Data.Maybe (fromJust)
    import Data.Ratio ((%))
  • replacement in test/Aftok/TimeLogSpec.hs at line 27
    [3.83053][2.2044:2127]()
    import Test.QuickCheck (Gen, forAll, sample', listOf, suchThat, arbitrary, choose)
    [3.83053]
    [3.2656]
    import Test.QuickCheck (Gen, arbitrary, choose, forAll, listOf, sample', suchThat)
    import Prelude hiding (head, tail)
  • edit in test/Aftok/TimeLogSpec.hs at line 78
    [3.83768][3.1756:1757]()
  • edit in test/Aftok/TimeLogSpec.hs at line 83
    [3.107193][3.1820:1821]()
  • edit in test/Aftok/TimeLogSpec.hs at line 87
    [3.4256][3.1822:1823]()
  • edit in test/Aftok/TimeLogSpec.hs at line 89
    [3.83869][3.1824:1825]()
  • edit in test/Aftok/TimeLogSpec.hs at line 91
    [3.1924][3.1924:1925]()
  • edit in test/Aftok/TimeLogSpec.hs at line 111
    [3.2098][3.2098:2099]()
  • replacement in test/Aftok/TimeLogSpec.hs at line 114
    [2.2664][2.2664:2715]()
    len = fromInteger @C.NominalDiffTime 360
    [2.2664]
    [2.2715]
    len = fromInteger @C.NominalDiffTime 3600
  • replacement in test/Aftok/TimeLogSpec.hs at line 118
    [3.2474][3.2474:2804]()
    . filter (\i -> fst i `mod` 2 == 0)
    $ ([(0 :: Int)..] `zip` (timestamps `zip` tail timestamps))
    widx = WorkIndex $ M.fromList
    [ (u0, L.fromList $ take 10 intervals)
    , (u1, L.fromList $ take 30 intervals)
    , (u2, L.fromList $ take 120 intervals)
    ]
    [3.2474]
    [3.2804]
    . filter (\i -> fst i `mod` 2 == 0)
    $ ([(0 :: Int) ..] `zip` (timestamps `zip` tail timestamps))
    widx =
    WorkIndex $
    M.fromList
    [ (u0, L.fromList $ take 10 intervals),
    (u1, L.fromList $ take 30 intervals),
    (u2, L.fromList $ take 120 intervals)
    ]
  • edit in test/Aftok/TimeLogSpec.hs at line 130
    [3.729][3.3975:3976](),[3.2104][3.3975:3976](),[3.2989][3.3975:3976](),[3.3832][3.3975:3976](),[3.71422][3.3975:3976](),[3.4083][3.3975:3976]()
  • replacement in test/Aftok/TimeLogSpec.hs at line 131
    [3.3036][2.2766:2852]()
    (shares ^. loggedTotal `shouldBe` (fromInteger @C.NominalDiffTime (360 * 160)))
    [3.3036]
    [3.3120]
    (shares ^. loggedTotal `shouldBe` (fromInteger @C.NominalDiffTime (3600 * 160)))
  • edit in test/Aftok/TimeLogSpec.hs at line 135
    [3.3406][3.3406:3407]()
  • edit in test/Aftok/TimeLogSpec.hs at line 168
    [3.3408][2.4274:4275]()