From d8e4af836991ae2cd8d63250dc69287ca7080169 Mon Sep 17 00:00:00 2001 From: Fabian Kirchner Date: Sat, 14 Oct 2023 14:41:55 +0200 Subject: refactor: simplify listIssues function --- app/History.hs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'app') diff --git a/app/History.hs b/app/History.hs index c04d16a..bd8af43 100644 --- a/app/History.hs +++ b/app/History.hs @@ -45,26 +45,10 @@ instance Exception InvalidTreeGrepperResult listIssues :: [Filter] -> [FilePath] -> IO [Issue] listIssues filters files = do commits <- fmap (lines . decodeUtf8 . L8.toStrict) $ sh ("git log --format=%H") - issueses <- - parMapM - ( \maybeCommit -> - case maybeCommit of - Nothing -> - listIssuesCurrent files - Just commit -> - cached commit (\_ -> listIssuesOf commit) - ) - $ (:) Nothing - $ map Just commits - (currentIssues, historicalIssues) <- - case issueses of - currentIssues : historicalIssueses -> - pure (currentIssues, concat historicalIssueses) - [] -> - die "no commits" - pure $ - map (merge . pick historicalIssues) $ - filter (applyFilter filters) currentIssues + currentIssues <- listIssuesCurrent files + historicalIssues <- fmap concat $ parMapM (\commit -> cached commit (\_ -> listIssuesOf commit)) commits + let currentIssuesFiltered = filter (applyFilter filters) currentIssues + pure $ map (merge . pick historicalIssues) currentIssuesFiltered pick :: [Issue] -> Issue -> (Issue, [Issue]) pick issues issue = -- cgit v1.2.3