Avoid divisions by zero & display depreciated time shares.
[?]
Feb 20, 2021, 3:32 AM
4WBBSPHBORAQYMQYVKVO4SLPUD5R2TI2WWIMRYMARNTWP5CQU22ACDependencies
- [2]
W3S6D7LUFix sample paths in DEVELOPMENT.md - [3]
ZHV75AENbasic cleanup - [4]
ZEAH247RShow all project contributors, not just those with a revenue share. - [5]
Z5KNL332Add skeleton of project overview HTML. - [6]
DZ7G36NCAllow first-revenue cutoff for depreciation. - [7]
PBD7LZYQPostgres & auth are beginning to function. - [8]
NJNMO72SAdd zcash.com submodule and update client to modern halogen. - [9]
7TQPQW3NBegin adding parsing for project detail. - [10]
HMDM3B55Implement core of payments/billing infrastructure. - [11]
NAFJ6RB3Minor module reorg. - [12]
M4PWY5RUPreliminary work to add support for Zcash payments. - [13]
EMVTF2IWWIP moving back to snap. - [14]
UWMGUJOWAutoformat sources. - [15]
46PUXHTYImplement project invitations. - [16]
APOATM4XAdd getProjectDetail call to project API - [17]
3GLHIR4FAdd migrate script for prod system. - [18]
W3PIWHDKFix logged hours display error. - [19]
PPW6ROC5Render project data - [20]
4QX5E5ACInitial compilation of payouts function succeeds. - [21]
NSRSSSTRUpdate nginx.conf, make aftok host configurable for cli scripts. - [22]
XXJFUZOVAdd first revenue date to project payout computation. - [23]
7HPY3QPFFix linting errors. (yay hlint!) - [24]
U7YAT2ZKAdd error reporting to signup form. - [25]
CI4OPKQMAdd payouts spec. - [26]
X3ES7NUAFine. I'll use ormolu. At least it doesn't break the code. - [27]
IR75ZMX3Return actual events for interval ends, not just timestamps. - [28]
GMYPBCWEMake docker-compose work. - [29]
7KZP4RHZSwitch from Data.Time to Data.Thyme - [*]
QAC2QJ32Add project overview page to client. - [*]
E2KOBKIJAdd setup script detailing the setup of the docker host. - [*]
NVOCQVASInitial failing tests.
Change contents
- replacement in DEVELOPMENT.md at line 115
following commands to initialize the database. The postgres user's password isspecified in the docker-compose file.`deploy/dbinit.sh` script to initialize the database. The postgres user's passwordcan be specified in the docker-compose file. - replacement in DEVELOPMENT.md at line 119
createuser -h localhost -U postgres -W -P aftokcreatedb -h localhost -U postgres -W -O aftok aftokpsql -h localhost -U aftok -W aftok < local/postgres/db-dumps/aftok.dump./deploy/dbinit.sh local/postgres/db-dumps/aftok.dump - replacement in client/src/Aftok/Api/Project.purs at line 104
, timeDevoted :: Hours, loggedHours :: Hours, depreciatedHours :: Hours - replacement in client/src/Aftok/Api/Project.purs at line 128
timeDevoted <- Hours <$> x .: "timeDevoted"loggedHours <- Hours <$> x .: "loggedHours"depreciatedHours <- Hours <$> x .: "depreciatedHours" - replacement in client/src/Aftok/Api/Project.purs at line 135
pure $ Contributor' { userId, handle, joinedOn, timeDevoted, revShare }pure $ Contributor' { userId, handle, joinedOn, loggedHours, depreciatedHours, revShare } - replacement in client/src/Aftok/Overview.purs at line 177
, colmd3 (Just "Contributed Hours"), colmd3 (Just "Current Revenue Share"), colmd2 (Just "Contributed"), colmd3 (Just "After Depreciation"), colmd3 (Just "Revenue Share") - replacement in client/src/Aftok/Overview.purs at line 230
, colmd3 (Just $ show (unwrap pud.timeDevoted)), colmd2 (Just $ show (unwrap pud.loggedHours) <> " hours"), colmd3 (Just $ show (unwrap pud.depreciatedHours) <> " hours") - replacement in client/src/Aftok/Overview.purs at line 298
, timeDevoted: Hours 100.0, loggedHours: Hours 100.0, depreciatedHours: Hours 75.0 - file addition: dbinit.sh[32.1]
#!/bin/bashcreateuser -h localhost -U postgres -W -P aftokcreatedb -h localhost -U postgres -W -O aftok aftokpsql -h localhost -U postgres -W aftok \-c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;'if [ -n "$1" ]; thenpsql -h localhost -U aftok -W aftok < $1fi - replacement in docker-compose.yml at line 81
source: aftok-datasource: v_aftok-data - replacement in docker-compose.yml at line 109
aftok-data:v_aftok-data: - edit in lib/Aftok/TimeLog.hs at line 114
deriving (Show, Eq) - edit in lib/Aftok/TimeLog.hs at line 123
deriving (Show, Eq) - replacement in lib/Aftok/TimeLog.hs at line 171
else max 0 (1 - (C.toSeconds (intervalAge ^-^ undepLength) / C.toSeconds depLength))elseif depLength == 0then 0else max 0 (1 - (C.toSeconds (intervalAge ^-^ undepLength) / C.toSeconds depLength)) - replacement in lib/Aftok/TimeLog.hs at line 202
withShareFraction t = t & wsShare .~ (C.toSeconds (t ^. wsDepreciated) / C.toSeconds totalTime)withShareFraction t =t & wsShare .~ (if totalTime == 0then 0else (C.toSeconds (t ^. wsDepreciated) / C.toSeconds totalTime)) - edit in server/Aftok/Snaplet/Projects.hs at line 39
wsDepreciated, - replacement in server/Aftok/Snaplet/Projects.hs at line 72
_timeDevoted :: Hours,_loggedHours :: Hours,_depreciatedHours :: Hours, - edit in server/Aftok/Snaplet/Projects.hs at line 120
- replacement in server/Aftok/Snaplet/Projects.hs at line 127
_timeDevoted = Hours . (`div` 3600) . round . C.toSeconds' $ ws ^. wsLogged,_loggedHours = Hours . (`div` 3600) . round . C.toSeconds' $ ws ^. wsLogged,_depreciatedHours = Hours . (`div` 3600) . round . C.toSeconds' $ ws ^. wsDepreciated, - edit in server/Aftok/Snaplet/Projects.hs at line 131
- replacement in server/Aftok/Snaplet/Projects.hs at line 133
zeroContrib = Contributor uid' h t (Hours 0) 0zeroContrib = Contributor uid' h t (Hours 0) (Hours 0) 0 - replacement in server/Aftok/Snaplet/Projects.hs at line 303
"timeDevoted" .= (c ^. timeDevoted . (to fromEnum)),"loggedHours" .= (c ^. loggedHours . (to fromEnum)),"depreciatedHours" .= (c ^. depreciatedHours . (to fromEnum)), - replacement in test/Aftok/TimeLogSpec.hs at line 15
import Aftok.Types (DepreciationFunction (..), UserId (..))import Aftok.Types (DepreciationFunction (..), DepreciationRules (..), UserId (..)) - edit in test/Aftok/TimeLogSpec.hs at line 25
import qualified Data.UUID as U - replacement in test/Aftok/TimeLogSpec.hs at line 129
depf = toDepF $ LinearDepreciation 180 1800depf = toDepF $ DepreciationRules (LinearDepreciation 180 1800) Nothing - edit in test/Aftok/TimeLogSpec.hs at line 136
it "correctly handles fully depreciated work intervals" $ donow <- C.getCurrentTimelet depf = toDepF $ DepreciationRules (LinearDepreciation 6 2) Nothingraw = [("b3ff64b7-6699-45f2-acee-38751325bf46", StartWork, "2021-02-09T15:52:13.434308+00"),("b3ff64b7-6699-45f2-acee-38751325bf46", StopWork, "2021-02-09T16:12:32.936579+00"),("d56ae5bd-8892-44c6-9a02-f6a8aca8636e", StartWork, "2021-02-09T16:23:10.637749+00"),("d56ae5bd-8892-44c6-9a02-f6a8aca8636e", StopWork, "2021-02-09T16:27:00.082747+00"),("d56ae5bd-8892-44c6-9a02-f6a8aca8636e", StartWork, "2021-02-09T16:29:10.119337+00"),("d56ae5bd-8892-44c6-9a02-f6a8aca8636e", StopWork, "2021-02-09T18:54:26.778107+00")]toEvent :: (String, C.UTCTime -> LogEvent, String) -> Maybe LogEntrytoEvent (uuid, f, t) =LogEntry <$> (CreditToUser . UserId <$> U.fromString uuid)<*> (f . C.toThyme <$> parseISO8601 t)<*> pure Nothingevents = catMaybes $ fmap toEvent rawwidx = workIndex (view event) eventsp = payouts depf now widxp `shouldBe` WorkShares 0 M.empty - replacement in test/Aftok/TimeLogSpec.hs at line 159
let depf = linearDepreciation 10 100let depf fr = linearDepreciation fr 10 100