summaryrefslogtreecommitdiff
path: root/Biz/Devalloc.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Devalloc.hs')
-rw-r--r--Biz/Devalloc.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/Biz/Devalloc.hs b/Biz/Devalloc.hs
index 938a16e..278ca12 100644
--- a/Biz/Devalloc.hs
+++ b/Biz/Devalloc.hs
@@ -1178,7 +1178,7 @@ analyze keep askedBy activeAuthors url bareRepo = do
{ analysisId = mempty,
stale =
[ (path, days)
- | (path, days) <- stalenessMap,
+ | (path, Just days) <- stalenessMap,
days > 180
],
score = calculateScore numTotal numBlackholes numLiabilities,
@@ -1220,7 +1220,7 @@ test_calculateScore =
Test.prop "never < 0" <| \t b l -> calculateScore t b l >= 0
]
-lastTouched :: FilePath -> FilePath -> IO (FilePath, Int)
+lastTouched :: FilePath -> FilePath -> IO (FilePath, Maybe Int)
lastTouched bareRepo path = do
now <- Time.getCurrentTime
timestamp <-
@@ -1236,10 +1236,10 @@ lastTouched bareRepo path = do
]
""
/> filter (/= '\n')
- -- TODO: this fails if time is empty?
- /> Time.parseTimeOrError True Time.defaultTimeLocale "%Y-%m-%dT%H:%M:%S%z"
- let days = round <| Time.diffUTCTime now timestamp / Time.nominalDay
- pure (path, days)
+ /> Time.parseTimeM True Time.defaultTimeLocale "%Y-%m-%dT%H:%M:%S%z"
+ pure (path, calculateAge now </ timestamp)
+ where
+ calculateAge now n = round <| Time.diffUTCTime now n / Time.nominalDay
-- | Given a git dir and a path inside the git repo, pure a list of tuples
-- with number of commits and author.