Skip to content

Commit

Permalink
Merge pull request #341 from ZIMkaRU/feature/add-lookup-query-for-app…
Browse files Browse the repository at this point in the history
…ropriate-starting-point-for-account-balances

Show users Account Balance started from wallet snapshot of start time point
  • Loading branch information
ezewer authored Dec 6, 2023
2 parents f21e78b + dc17d4d commit ab2d6d2
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions workers/loc.api/sync/balance.history/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,29 +447,10 @@ class BalanceHistory {
}]
}

async _getStartingMts (
args,
groupedWallets
) {
if (
Array.isArray(groupedWallets) &&
groupedWallets.length > 0 &&
groupedWallets[groupedWallets.length - 1] &&
typeof groupedWallets[groupedWallets.length - 1] === 'object' &&
Number.isInteger(groupedWallets[groupedWallets.length - 1].mts)
) {
return groupedWallets[groupedWallets.length - 1].mts
}

const firstWalletsMts = await this.wallets.getFirstWalletsMts(args)

if (Number.isInteger(firstWalletsMts)) {
return firstWalletsMts
}

const { start = 0 } = args?.params ?? {}

return start
async _getStartingMts (args) {
return Number.isInteger(args?.params?.start)
? args.params.start
: await this.wallets.getFirstWalletsMts(args)
}

async getBalanceHistory (
Expand Down Expand Up @@ -545,10 +526,7 @@ class BalanceHistory {
'currency',
this._calcWalletsInTimeframe(firstWallets)
)
const startingMts = await this._getStartingMts(
args,
walletsGroupedByTimeframe
)
const startingMts = await this._getStartingMts(args)
const mtsGroupedByTimeframe = getMtsGroupedByTimeframe(
startingMts,
end,
Expand Down

0 comments on commit ab2d6d2

Please sign in to comment.