summaryrefslogtreecommitdiff
path: root/Biz
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-02-19 19:38:10 -0500
committerBen Sima <ben@bsima.me>2021-02-19 19:38:10 -0500
commitf1cc339de587ac7897b09d75c0eb79569ea54602 (patch)
treeb204f296155a220996ef08018807067e524b713b /Biz
parent390e60acd1066305a1b19274c08e2c7f1ab1908c (diff)
Don't blow up when git mtime is empty
Diffstat (limited to 'Biz')
-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.