Add 'loggedIntervals' endpoint.

[?]
Jan 17, 2015, 6:52 PM
7XN3I3QJHYMKU2DCUXX34WQMSJ4ZJOWW7FME34EANO3E5W4Q632AC

Dependencies

  • [2] XMONXALY Fix sqlite/readWorkIndex table name
  • [3] 2Y2QZFVF Switch to more modern cabal2nix-based workflow.
  • [4] ADMKQQGC Initial empty Snap project.
  • [5] WFZDMVUX Rename ADB -> QDB
  • [6] A2J7B4SC Initial impl of depreciation function.
  • [7] WZUHEZSB Start of migration back toward snap.
  • [8] Y35QCWYW Minor improvement in WorkIndex type to eliminate duplicated information.
  • [9] EMVTF2IW WIP moving back to snap.
  • [10] 2OIPAQCB Merge branch 'master' of github.com:nuttycom/ananke
  • [11] TLQ72DSJ Lenses, sqlite-simple
  • [12] FRPWIKCN Added log event parsing to Quixotic.Database.SQLite
  • [13] N4NDAZYT Initial implementation of payouts.
  • [14] 4QX5E5AC Initial compilation of payouts function succeeds.
  • [15] NVOCQVAS Initial failing tests.
  • [16] 2KZPOGRB Once you get Haskell to compile, the tests pass!
  • [17] JUUMYIQE Add groupBy utility function for use in TimeLog.
  • [18] RSEB2NFG Replacing Snap with Scotty.
  • [19] EQXRXRZD Changed to use tasty instead of test-framework
  • [20] GKGVYBZG Added JSON serialization to TimeLog
  • [21] 64C6AWH6 Rename Ananke -> Quixotic, project reboot.
  • [22] 7DBNV3GV Initial, stack-based impl of time log event reduction.
  • [23] 64VI73NP Server now compiles using abstracted SQLite
  • [24] TCOAKCGG Completed conversion to snap.

Change contents

  • replacement in lib/Quixotic/Database/SQLite.hs at line 79
    [2.143][4.1913:1969](),[4.1913][4.1913:1969]()
    lift . return . workIndex $ fmap (^. _PLogEntry) rows
    [2.143]
    [4.416]
    lift . pure . workIndex $ fmap (^. _PLogEntry) rows
  • edit in lib/Quixotic/Interval.hs at line 2
    [4.464]
    [4.464]
    {-# LANGUAGE OverloadedStrings #-}
  • edit in lib/Quixotic/Interval.hs at line 9
    [4.487]
    [4.1494]
    import Data.Aeson
  • edit in lib/Quixotic/Interval.hs at line 16
    [4.1681]
    [4.1681]
    instance ToJSON Interval where
    toJSON (Interval s e) =
    object ["start" .= s, "end" .= e]
  • edit in lib/Quixotic/Interval.hs at line 21
    [4.1682]
    [4.2576]
    instance FromJSON Interval where
    parseJSON (Object v) = Interval <$> v .: "start" <*> v .: "end"
    parseJSON _ = mzero
  • edit in lib/Quixotic/TimeLog.hs at line 26
    [4.587][4.168:186](),[4.2644][4.168:186](),[4.3656][4.168:186](),[4.119][4.168:186]()
    import Data.Aeson
  • edit in lib/Quixotic/TimeLog.hs at line 50
    [4.4084][4.4084:4085](),[4.4085][4.302:336](),[4.1283][4.302:336](),[4.336][4.4086:4188](),[4.4188][4.2737:2759](),[4.539][4.2737:2759]()
    instance FromJSON WorkEvent where
    parseJSON (Object jv) =
    WorkEvent <$> (jv .: "type" >>= nameEvent) <*> jv .: "timestamp"
    parseJSON _ = mzero
  • edit in lib/Quixotic/TimeLog.hs at line 57
    [4.1725][4.638:671](),[4.671][4.4262:4344](),[4.800][4.2123:2124](),[4.4344][4.2123:2124](),[4.2123][4.2123:2124](),[4.2124][4.801:823](),[4.793][4.2285:2286](),[4.823][4.2285:2286](),[4.2285][4.2285:2286]()
    instance FromJSON LogEntry where
    parseJSON (Object jv) =
    LogEntry <$> jv .: "btcAddr" <*> jv .: "workEvent"
    parseJSON _ = mzero
  • replacement in lib/Quixotic/TimeLog.hs at line 62
    [4.2287][4.794:849]()
    type WorkIndex = Map BtcAddr ([WorkEvent], [Interval])
    [4.2287]
    [4.123]
    type WorkIndex = Map BtcAddr [Interval]
  • edit in lib/Quixotic/TimeLog.hs at line 65
    [4.88]
    [4.350]
    type RawIndex = Map BtcAddr ([LogEntry], [LogInterval])
  • replacement in lib/Quixotic/TimeLog.hs at line 83
    [4.1052][4.733:884]()
    (totalTime, keyTimes) = MS.mapAccum addIntervalDiff (fromInteger 0) $ MS.map snd widx
    in MS.map (\kt -> toRational $ kt / totalTime) keyTimes
    [4.1052]
    [4.1011]
    (totalTime, keyTimes) = MS.mapAccum addIntervalDiff (fromInteger 0) $ widx
    in fmap (\kt -> toRational $ kt / totalTime) keyTimes
  • replacement in lib/Quixotic/TimeLog.hs at line 106
    [4.4504][4.4504:4572]()
    in MS.map (bimap (fmap (^. event)) (fmap workInterval)) $ logSum
    [4.4504]
    [4.448]
    in fmap (fmap workInterval . snd) $ logSum
  • edit in lib/Quixotic/TimeLog.hs at line 108
    [4.449][4.2009:2065](),[4.654][4.25:26](),[4.2065][4.25:26](),[4.2419][4.25:26]()
    type RawIndex = Map BtcAddr ([LogEntry], [LogInterval])
  • edit in lib/Quixotic/TimeLog.hs at line 140
    [4.3036][4.1182:1736](),[4.1182][4.1182:1736](),[4.1736][4.588:588](),[4.588][4.441:442](),[4.441][4.441:442]()
    -- data LogEventParseError = LogEventParseError String deriving (Show, Typeable)
    -- instance Exception LogEventParseError where
    -- instance FromField WorkEvent where
    -- fromField f m = let fromText "start_work" = return StartWork
    -- fromText "stop_work" = return StopWork
    -- fromText a = conversionError $ LogEventParseError $ "unrecognized log event type " ++ a
    -- in fromField f m >>= fromText
    -- instance FromRow LogEntry where
    -- fromRow = LogEntry <$> field <*> field <*> field
  • edit in server/Main.hs at line 8
    [4.5260]
    [4.191]
    import Control.Lens
  • edit in server/Main.hs at line 13
    [3.170]
    [4.226]
    import Data.Map
  • edit in server/Main.hs at line 37
    [4.468]
    [4.468]
    , ("loggedIntervals/:btcAddr", loggedIntervals qdb)
  • edit in server/Main.hs at line 83
    [4.6063]
    [4.323]
    loggedIntervals :: QDB IO a -> ReaderT a Snap ()
    loggedIntervals qdb = do
    let QDB{..} = qdb
    widx <- mapReaderT liftIO $ readWorkIndex
    lift . modifyResponse $ addHeader "content-type" "application/json"
    lift . writeLBS . A.encode $ mapKeys (^. address) widx
  • edit in server/Main.hs at line 94
    [4.985][4.758:759](),[4.3188][4.758:759]()