Skip to content

Commit

Permalink
descriptions: Leverage ICU to get better description/payee/note sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jul 15, 2019
1 parent 7e332fd commit 3b0661c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions hledger/Hledger/Cli/Commands/Descriptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module Hledger.Cli.Commands.Descriptions (
#if !(MIN_VERSION_base(4,11,0))
import Data.Monoid
#endif
import Data.List
import Data.List.Extra (nubSortBy)
import qualified Data.Text.ICU as T
import qualified Data.Text.IO as T

import Hledger
Expand All @@ -39,6 +40,6 @@ descriptions CliOpts{reportopts_=ropts} j = do
d <- getCurrentDay
let q = queryFromOpts d ropts
ts = entriesReport ropts q j
descriptions = nub $ sort $ map tdescription ts
descriptions = nubSortBy (T.compare [T.CompareIgnoreCase]) $ map tdescription ts

mapM_ T.putStrLn descriptions
5 changes: 3 additions & 2 deletions hledger/Hledger/Cli/Commands/Notes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module Hledger.Cli.Commands.Notes (
#if !(MIN_VERSION_base(4,11,0))
import Data.Monoid
#endif
import Data.List
import Data.List.Extra (nubSortBy)
import qualified Data.Text.ICU as T
import qualified Data.Text.IO as T

import Hledger
Expand All @@ -39,6 +40,6 @@ notes CliOpts{reportopts_=ropts} j = do
d <- getCurrentDay
let q = queryFromOpts d ropts
ts = entriesReport ropts q j
notes = nub $ sort $ map transactionNote ts
notes = nubSortBy (T.compare [T.CompareIgnoreCase]) $ map transactionNote ts

mapM_ T.putStrLn notes
5 changes: 3 additions & 2 deletions hledger/Hledger/Cli/Commands/Payees.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module Hledger.Cli.Commands.Payees (
#if !(MIN_VERSION_base(4,11,0))
import Data.Monoid
#endif
import Data.List
import Data.List.Extra (nubSortBy)
import qualified Data.Text.ICU as T
import qualified Data.Text.IO as T

import Hledger
Expand All @@ -39,6 +40,6 @@ payees CliOpts{reportopts_=ropts} j = do
d <- getCurrentDay
let q = queryFromOpts d ropts
ts = entriesReport ropts q j
payees = nub $ sort $ map transactionPayee ts
payees = nubSortBy (T.compare [T.CompareIgnoreCase]) $ map transactionPayee ts

mapM_ T.putStrLn payees
2 changes: 2 additions & 0 deletions hledger/hledger.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ library
, data-default >=0.5
, directory
, easytest >=0.2.1 && <0.3
, extra
, filepath
, hashable >=1.2.4
, haskeline >=0.6
Expand All @@ -179,6 +180,7 @@ library
, tabular >=0.2
, temporary
, text >=0.11
, text-icu
, time >=1.5
, timeit
, transformers
Expand Down
2 changes: 2 additions & 0 deletions hledger/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ dependencies:
- Decimal
- directory
- easytest >= 0.2.1 && <0.3
- extra
- filepath
- haskeline >=0.6
- megaparsec >=7.0.0 && <8
Expand All @@ -136,6 +137,7 @@ dependencies:
- tabular >=0.2
- temporary
- text >=0.11
- text-icu
- time >=1.5
- timeit
- transformers
Expand Down

0 comments on commit 3b0661c

Please sign in to comment.