mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
33 lines
855 B
Go
33 lines
855 B
Go
package engine
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/formancehq/ledger/internal/storage/ledgerstore"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type Stats struct {
|
|
Transactions int `json:"transactions"`
|
|
Accounts int `json:"accounts"`
|
|
}
|
|
|
|
func (l *Ledger) Stats(ctx context.Context) (Stats, error) {
|
|
var stats Stats
|
|
|
|
transactions, err := l.store.CountTransactions(ctx, ledgerstore.NewGetTransactionsQuery(ledgerstore.NewPaginatedQueryOptions(ledgerstore.PITFilterWithVolumes{})))
|
|
if err != nil {
|
|
return stats, errors.Wrap(err, "counting transactions")
|
|
}
|
|
|
|
accounts, err := l.store.CountAccounts(ctx, ledgerstore.NewGetAccountsQuery(ledgerstore.NewPaginatedQueryOptions(ledgerstore.PITFilterWithVolumes{})))
|
|
if err != nil {
|
|
return stats, errors.Wrap(err, "counting accounts")
|
|
}
|
|
|
|
return Stats{
|
|
Transactions: transactions,
|
|
Accounts: accounts,
|
|
}, nil
|
|
}
|