Enabling logging of time to contributor/project accounts
[?]
Jun 19, 2016, 9:20 PM
POX3UAMTGCNS3SU5I6IKDNCCSHEAUSFBZ3WCMQ3EXKPNXETOI6BACDependencies
- [2]
373LXH2XAdd MAYBE.md, update task list. - [3]
ASF3UPJLAdd auction creation and bid handlers - [4]
Z7KS5XHHVery WIP. Wow. - [5]
7HPY3QPFFix linting errors. (yay hlint!) - [6]
N4NDAZYTInitial implementation of payouts. - [7]
KNSI575VCleanup of EventLog types. - [8]
NEDDHXUKReformat via stylish-haskell - [9]
7DBNV3GVInitial, stack-based impl of time log event reduction. - [10]
AVDFWICBMore musings for the TASKS file. - [11]
5DRIWGLUImproving TimeLog specs - [12]
W35DDBFYFactor common JSON conversions up into client lib module. - [13]
EZQG2APBUpdate task list. - [14]
NVOCQVASInitial failing tests. - [15]
7XN3I3QJAdd 'loggedIntervals' endpoint. - [16]
4U7F3CPITHE GREAT RENAMING OF THINGS! - [17]
Y35QCWYWMinor improvement in WorkIndex type to eliminate duplicated information. - [18]
GKGVYBZGAdded JSON serialization to TimeLog - [19]
MGOF7IUFUpdate TASKS list to reflect completed projects. - [20]
GCVQD44VCreate amends endpoint, switch to UUID primary keys - [21]
SLL7262CMake depreciation functions more flexible. - [22]
HALRDT2FAdded initial auction create route. - [23]
RPAJLHMTChange to use UUIDs instead of ints for primary keys. - [24]
NLZ3JXLOFix formatting with stylish-haskell. - [25]
QMRKFEPGRefactor QDB to use a free monad algebra instead. - [26]
64C6AWH6Rename Ananke -> Quixotic, project reboot. - [27]
A6HKMINBAttempting to improve JSON handling. - [28]
SCXG6TJWMake log reduction safer in presence of overlapping events. - [29]
OV5AKJHARemove unused LogInterval type. - [30]
O5FVTOM6Undo JSON silliness, enable a couple more routes. - [31]
TLQ72DSJLenses, sqlite-simple - [*]
2XQD6KKKAdd invitation logic and clean up DBProg error handling. - [*]
7KZP4RHZSwitch from Data.Time to Data.Thyme
Change contents
- edit in TASKS.md at line 26
* Events* User-identified events- Associate events with user identifier as well as BTC address, and addlate resolution of BTC addresses at point of payout calculation. - replacement in TASKS.md at line 35
* Payouts should not include events younger than <commit_delay hours> to permit amends.* Payouts should not include events younger than <commit_delay hours> to permit amends. - replacement in TASKS.md at line 41
* Include hours won in resource auction - requires confirmation that contribution* Include hours won in resource auction - requires confirmation that contribution - Kris wip - edit in TASKS.md at line 43
* Ensure that we avoid creating dust transactions on the blockchain. Any payout fragmentfalling below the estimated cost of redemption should be instead deducted from thecost to the purchaser? - replacement in TASKS.md at line 56
Webserver---------Server------ - replacement in TASKS.md at line 68
Payouts Service---------------Scheduled event Service----------------------- - replacement in TASKS.md at line 71
* Read blockchain transactions* Payout Address Update validation* Based on blockchain transactions: - edit in aftok.cabal at line 64[33.1051][34.2887]
, unordered-containers - edit in lib/Aftok/Json.hs at line 16
import Data.HashMap.Strict as O - edit in lib/Aftok/Json.hs at line 75
v2 :: Value -> Valuev2 = versioned $ Version 2 0 - replacement in lib/Aftok/Json.hs at line 80[4.4963]→[4.4963:4979](∅→∅),[4.4979]→[4.1605:1631](∅→∅),[4.1631]→[4.5006:5114](∅→∅),[4.5006]→[4.5006:5114](∅→∅)
unv1 name f v =let p (Version 1 0) = fp ver = const . fail $ "Unrecognized " <> name <> " schema version: " <> show verin unversion p vunv1 name f = unversion $ \x -> case x ofVersion 1 0 -> f_ -> badVersion name xbadVersion :: String -> Version -> Value -> Parser abadVersion name ver = const . fail $ "Unrecognized " <> name <> " schema version: " <> show ver - edit in lib/Aftok/Json.hs at line 123
creditToJSON :: CreditTo -> ValuecreditToJSON (CreditToAddress addr) = v2 $ object [ "creditToAddress" .= addr ]creditToJSON (CreditToUser uid) = v2 $ object [ "creditToUser" .= (uid ^. _UserId) ]creditToJSON (CreditToProject pid) = v2 $ object [ "creditToProject" .= projectIdJSON pid ] - replacement in lib/Aftok/Json.hs at line 130
toJSON $ MS.mapKeys (^. _BtcAddr) mtoJSON $ (creditToJSON *** id) <$> MS.assocs m - replacement in lib/Aftok/Json.hs at line 132
workIndexJSON :: WorkIndex -> ValueworkIndexJSON (WorkIndex widx) = v1 $toJSON $ (L.toList . fmap intervalJSON) <$> MS.mapKeysMonotonic (^._BtcAddr) widxworkIndexJSONV1 :: WorkIndex -> ValueworkIndexJSONV1 (WorkIndex widx) = v1 $toJSON $ (L.toList . fmap intervalJSON) <$>MS.mapKeysMonotonic (^? (_CreditToAddress._BtcAddr)) widx - replacement in lib/Aftok/Json.hs at line 142
logEntryJSON (LogEntry a ev m) = v1 $object [ "btcAddr" .= (a ^. _BtcAddr)logEntryJSON (LogEntry c ev m) = v2 $object [ "creditTo" .= creditToJSON c - replacement in lib/Aftok/Json.hs at line 159
Payouts . MS.mapKeys BtcAddr <$> parseJSON vPayouts . MS.mapKeys (CreditToAddress . BtcAddr) <$> parseJSON v - replacement in lib/Aftok/Json.hs at line 162[4.5925]→[4.1745:1769](∅→∅),[4.1769]→[4.5950:6047](∅→∅),[4.5950]→[4.5950:6047](∅→∅),[4.6047]→[4.1770:1919](∅→∅),[4.1919]→[4.6202:6236](∅→∅),[4.6202]→[4.6202:6236](∅→∅),[4.6236]→[4.1920:1954](∅→∅),[4.1954]→[4.6271:6317](∅→∅),[4.6271]→[4.6271:6317](∅→∅),[4.6317]→[4.1955:1978](∅→∅),[4.1978]→[4.6341:6406](∅→∅),[4.6341]→[4.6341:6406](∅→∅)
parseEventAmendment t =let parseA x "timeChange" = TimeChange t <$> x .: "eventTime"parseA x "addrChage" = doaddrText <- x .: "btcAddr"maybe(fail $ show addrText <> "is not a valid BTC address")(pure . AddressChange t)$ parseBtcAddr addrTextparseA x "metadataChange" =MetadataChange t <$> x .: "eventMeta"parseA _ other =fail $ "Amendment value " <> other <> " not recognized."parseEventAmendment t = unversion $ \v -> case v ofVersion 1 0 -> parseEventAmendmentV1 tVersion 2 0 -> parseEventAmendmentV2 t_ -> badVersion "EventAmendment" vparseEventAmendmentV1 :: ModTime -> Value -> Parser EventAmendmentparseEventAmendmentV1 t v@(Object x) =let parseA :: Text -> Parser EventAmendmentparseA "timeChange" = TimeChange t <$> x .: "eventTime"parseA "addrChange" = CreditToChange t <$> parseCreditTo vparseA "metadataChange" = MetadataChange t <$> x .: "eventMeta"parseA id = fail . show $ "Amendment type " <> id <> " not recognized."in x .: "amendment" >>= parseAparseEventAmendmentV1 t x =fail $ "Value " <> show x <> " is not a JSON object."parseEventAmendmentV2 :: ModTime -> Value -> Parser EventAmendmentparseEventAmendmentV2 t v@(Object x) =let parseA :: Text -> Parser EventAmendmentparseA "timeChange" = TimeChange t <$> x .: "eventTime"parseA "creditToChange" = CreditToChange t <$> parseCreditTo vparseA "metadataChange" = MetadataChange t <$> x .: "eventMeta"parseA id = fail . show $ "Amendment type " <> id <> " not recognized."in x .: "amendment" >>= parseAparseEventAmendmentV2 t x =fail $ "Value " <> show x <> " is not a JSON object."parseBtcAddrJson :: Value -> Parser BtcAddrparseBtcAddrJson v = dot <- parseJSON vmaybe (fail $ show t <> " is not a valid BTC address") pure $ parseBtcAddr t - replacement in lib/Aftok/Json.hs at line 196
p (Object x) = x .: "amendment" >>= parseA xp x = fail $ "Value " <> show x <> " missing 'amendment' field."in unv1 "amendment" pparseCreditTo :: Value -> Parser CreditToparseCreditTo = unversion $ \x -> case x ofVersion 1 0 -> withObject "BtcAddr" parseCreditToV1Version 2 0 -> withObject "CreditTo" parseCreditToV2_ -> badVersion "EventAmendment" xparseCreditToV1 :: Object -> Parser CreditToparseCreditToV1 x = CreditToAddress <$> (parseBtcAddrJson =<< (x .: "btcAddr")) - edit in lib/Aftok/Json.hs at line 205[4.6555]
parseCreditToV2 :: Object -> Parser CreditToparseCreditToV2 x =let parseCreditToAddr (Object x') = doaddrText <- O.lookup "creditToAddress" x'pure (CreditToAddress <$> parseBtcAddrJson addrText)parseCreditToAddr x' = NothingparseCreditToUser (Object x') = NothingparseCreditToUser x' = NothingparseCreditToProject (Object x') = NothingparseCreditToProject x' = NothingnotFound = fail $ "Value " <> show x <> " does not represent a CreditTo value."parseV v = (parseCreditToAddr v <|> parseCreditToUser v <|> parseCreditToProject v)in dobody <- x .: "creditTo"fromMaybe notFound $ parseV body - replacement in lib/Aftok/Project.hs at line 15
newtype ProjectId = ProjectId UUID deriving (Show, Eq)newtype ProjectId = ProjectId UUID deriving (Show, Eq, Ord) - replacement in lib/Aftok/TimeLog.hs at line 5[4.1805]→[4.907:924](∅→∅),[4.4159]→[4.907:924](∅→∅),[4.5325]→[4.907:924](∅→∅),[4.907]→[4.907:924](∅→∅),[4.924]→[4.1083:1130](∅→∅),[4.1130]→[4.2033:2069](∅→∅)
( LogEntry(..), btcAddr, event, eventMeta, LogEvent(..), eventName, nameEvent, eventTime( LogEntry(..), creditTo, event, eventMeta, CreditTo(..), _CreditToAddress, _CreditToUser, _CreditToProject, LogEvent(..), eventName, nameEvent, eventTime - edit in lib/Aftok/TimeLog.hs at line 36
import Aftok.Project (ProjectId) - edit in lib/Aftok/TimeLog.hs at line 57
data CreditTo-- payouts are made directly to this address, or to an address replacing this one= CreditToAddress BtcAddr-- payouts are distributed as requested by the specified contributor| CreditToUser UserId-- payouts are distributed to this project's contributors| CreditToProject ProjectIdderiving (Show, Eq, Ord)makePrisms ''CreditTo - replacement in lib/Aftok/TimeLog.hs at line 69
{ _btcAddr :: BtcAddr{ _creditTo :: CreditTo - replacement in lib/Aftok/TimeLog.hs at line 77
let ordElems e = (e ^. event, e ^. btcAddr)let ordElems e = (e ^. event, e ^. creditTo) - replacement in lib/Aftok/TimeLog.hs at line 87
| AddressChange ModTime BtcAddr| CreditToChange ModTime CreditTo - replacement in lib/Aftok/TimeLog.hs at line 93
newtype Payouts = Payouts (Map BtcAddr Rational)newtype Payouts = Payouts (Map CreditTo Rational) - replacement in lib/Aftok/TimeLog.hs at line 96
newtype WorkIndex = WorkIndex (Map BtcAddr (NonEmpty Interval)) deriving (Show, Eq)newtype WorkIndex = WorkIndex (Map CreditTo (NonEmpty Interval)) deriving (Show, Eq) - replacement in lib/Aftok/TimeLog.hs at line 148
type RawIndex = Map BtcAddr [Either LogEvent Interval]type RawIndex = Map CreditTo [Either LogEvent Interval] - replacement in lib/Aftok.hs at line 27
newtype UserId = UserId UUID deriving (Show, Eq)newtype UserId = UserId UUID deriving (Show, Eq, Ord)