Add 'loggedIntervals' endpoint.
[?]
Jan 17, 2015, 6:52 PM
7XN3I3QJHYMKU2DCUXX34WQMSJ4ZJOWW7FME34EANO3E5W4Q632ACDependencies
- [2]
XMONXALYFix sqlite/readWorkIndex table name - [3]
2Y2QZFVFSwitch to more modern cabal2nix-based workflow. - [4]
ADMKQQGCInitial empty Snap project. - [5]
WFZDMVUXRename ADB -> QDB - [6]
A2J7B4SCInitial impl of depreciation function. - [7]
WZUHEZSBStart of migration back toward snap. - [8]
Y35QCWYWMinor improvement in WorkIndex type to eliminate duplicated information. - [9]
EMVTF2IWWIP moving back to snap. - [10]
2OIPAQCBMerge branch 'master' of github.com:nuttycom/ananke - [11]
TLQ72DSJLenses, sqlite-simple - [12]
FRPWIKCNAdded log event parsing to Quixotic.Database.SQLite - [13]
N4NDAZYTInitial implementation of payouts. - [14]
4QX5E5ACInitial compilation of payouts function succeeds. - [15]
NVOCQVASInitial failing tests. - [16]
2KZPOGRBOnce you get Haskell to compile, the tests pass! - [17]
JUUMYIQEAdd groupBy utility function for use in TimeLog. - [18]
RSEB2NFGReplacing Snap with Scotty. - [19]
EQXRXRZDChanged to use tasty instead of test-framework - [20]
GKGVYBZGAdded JSON serialization to TimeLog - [21]
64C6AWH6Rename Ananke -> Quixotic, project reboot. - [22]
7DBNV3GVInitial, stack-based impl of time log event reduction. - [23]
64VI73NPServer now compiles using abstracted SQLite - [24]
TCOAKCGGCompleted conversion to snap.
Change contents
- replacement in lib/Quixotic/Database/SQLite.hs at line 79
lift . return . workIndex $ fmap (^. _PLogEntry) rowslift . pure . workIndex $ fmap (^. _PLogEntry) rows - edit in lib/Quixotic/Interval.hs at line 2
{-# LANGUAGE OverloadedStrings #-} - edit in lib/Quixotic/Interval.hs at line 9
import Data.Aeson - edit in lib/Quixotic/Interval.hs at line 16
instance ToJSON Interval wheretoJSON (Interval s e) =object ["start" .= s, "end" .= e] - edit in lib/Quixotic/Interval.hs at line 21
instance FromJSON Interval whereparseJSON (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 whereparseJSON (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 whereparseJSON (Object jv) =LogEntry <$> jv .: "btcAddr" <*> jv .: "workEvent"parseJSON _ = mzero - replacement in lib/Quixotic/TimeLog.hs at line 62
type WorkIndex = Map BtcAddr ([WorkEvent], [Interval])type WorkIndex = Map BtcAddr [Interval] - edit in lib/Quixotic/TimeLog.hs at line 65
type RawIndex = Map BtcAddr ([LogEntry], [LogInterval]) - replacement in lib/Quixotic/TimeLog.hs at line 83
(totalTime, keyTimes) = MS.mapAccum addIntervalDiff (fromInteger 0) $ MS.map snd widxin MS.map (\kt -> toRational $ kt / totalTime) keyTimes(totalTime, keyTimes) = MS.mapAccum addIntervalDiff (fromInteger 0) $ widxin fmap (\kt -> toRational $ kt / totalTime) keyTimes - replacement in lib/Quixotic/TimeLog.hs at line 106
in MS.map (bimap (fmap (^. event)) (fmap workInterval)) $ logSumin fmap (fmap workInterval . snd) $ logSum - edit in lib/Quixotic/TimeLog.hs at line 108
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
import Control.Lens - edit in server/Main.hs at line 13
import Data.Map - edit in server/Main.hs at line 37
, ("loggedIntervals/:btcAddr", loggedIntervals qdb) - edit in server/Main.hs at line 83
loggedIntervals :: QDB IO a -> ReaderT a Snap ()loggedIntervals qdb = dolet QDB{..} = qdbwidx <- mapReaderT liftIO $ readWorkIndexlift . modifyResponse $ addHeader "content-type" "application/json"lift . writeLBS . A.encode $ mapKeys (^. address) widx - edit in server/Main.hs at line 94