Skip to content

Commit

Permalink
Frontend.Console: show progress at balance check
Browse files Browse the repository at this point in the history
Show progress when checking balances so that we can know which
currency is the slow one.

Fixes #245
  • Loading branch information
webwarrior-ws authored and knocte committed Jan 19, 2024
1 parent b05b90e commit b72bb86
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/GWallet.Frontend.Console/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,12 @@ let rec ProgramMainLoop() =

Console.WriteLine ()
Console.WriteLine "*** STATUS ***"
Console.WriteLine ()

let lines =
UserInteraction.DisplayAccountStatuses(WhichAccount.All activeAccounts)
|> Async.RunSynchronously
Console.WriteLine Environment.NewLine
Console.WriteLine (String.concat Environment.NewLine lines)
Console.WriteLine ()

Expand Down
7 changes: 7 additions & 0 deletions src/GWallet.Frontend.Console/UserInteraction.fs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ module UserInteraction =
// we don't need to query the fiat value at all (micro-optimization?)
let! balance,usdValue = FSharpUtil.AsyncExtensions.MixedParallel2 balanceJob usdValueJob

let progressIteration = sprintf " %A" account.Currency
Console.Write progressIteration

return (account,balance,usdValue)
}

Expand All @@ -264,6 +267,7 @@ module UserInteraction =
let private GetAccountBalances (accounts: seq<IAccount>)
: Async<array<IAccount*MaybeCached<decimal>*MaybeCached<decimal>>> =
let accountAndBalancesToBeQueried = accounts |> Seq.map GetAccountBalanceInner
Console.Write "Retrieving balances..."
Async.Parallel accountAndBalancesToBeQueried

let DisplayAccountStatuses(whichAccount: WhichAccount): Async<seq<string>> =
Expand Down Expand Up @@ -343,6 +347,9 @@ module UserInteraction =
let! accountsWithBalances = GetAccountBalances accounts
let statuses, currencyTotals = displayAllAndSumBalance accountsWithBalances 0 Map.empty

// All balances are fetched and their currency names printed, put a dot at the end of "Retrieving balances... " line.
Console.Write '.'

let maybeTotalInUsd, totals = displayTotalAndSumFiatBalance currencyTotals
return
seq {
Expand Down

0 comments on commit b72bb86

Please sign in to comment.