diff options
author | Fabian Kirchner <kirchner@posteo.de> | 2023-10-14 14:41:55 +0200 |
---|---|---|
committer | Fabian Kirchner <kirchner@posteo.de> | 2023-10-14 14:41:55 +0200 |
commit | d8e4af836991ae2cd8d63250dc69287ca7080169 (patch) | |
tree | 818752f8ee9167c97cad0aeaceff9262e3d1778d /app | |
parent | a88672dac3bdef836023a0fa66ef4ccc69d7f0ca (diff) |
refactor: simplify listIssues function
Diffstat (limited to 'app')
-rw-r--r-- | app/History.hs | 24 |
1 files changed, 4 insertions, 20 deletions
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 = |