We now do data filtering/massage as late as possible, not just once at startup. This should work better for multiple commands, as with web or ui. The basic benchmark seems at least as good as before thanks to laziness.
		
			
				
	
	
		
			27 lines
		
	
	
		
			684 B
		
	
	
	
		
			Haskell
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			684 B
		
	
	
	
		
			Haskell
		
	
	
	
	
	
| {-| 
 | |
| 
 | |
| A ledger-compatible @print@ command.
 | |
| 
 | |
| -}
 | |
| 
 | |
| module Commands.Print
 | |
| where
 | |
| import Prelude hiding (putStr)
 | |
| import Ledger
 | |
| import Options
 | |
| import System.IO.UTF8
 | |
| 
 | |
| 
 | |
| -- | Print ledger transactions in standard format.
 | |
| print' :: [Opt] -> [String] -> Ledger -> IO ()
 | |
| print' opts args l = do
 | |
|   t <- getCurrentLocalTime
 | |
|   putStr $ showTransactions (optsToFilterSpec opts args t) l
 | |
| 
 | |
| showTransactions :: FilterSpec -> Ledger -> String
 | |
| showTransactions filterspec l =
 | |
|     concatMap (showTransactionForPrint effective) $ sortBy (comparing tdate) txns
 | |
|         where
 | |
|           effective = EffectiveDate == whichdate filterspec
 | |
|           txns = jtxns $ filterJournalTransactions filterspec $ journal l
 |