From f1cc339de587ac7897b09d75c0eb79569ea54602 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 19 Feb 2021 19:38:10 -0500 Subject: Don't blow up when git mtime is empty --- Biz/Devalloc.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Biz/Devalloc.hs') 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