API: add index size to stats

This commit is contained in:
Drew DeVault 2022-07-11 21:38:29 +02:00
parent 53eefd6787
commit ed9031a3a3
2 changed files with 4 additions and 2 deletions

View file

@ -33,6 +33,7 @@ type Result {
type Stats {
npages: Int!
ndomains: Int!
indexbytes: Int!
}
type Query {

View file

@ -82,8 +82,9 @@ func (r *queryResolver) Stats(ctx context.Context) (*model.Stats, error) {
row := tx.QueryRowContext(ctx, `
SELECT
(SELECT count(*) FROM page),
(SELECT count(*) FROM domain);`)
return row.Scan(&stats.Npages, &stats.Ndomains)
(SELECT count(*) FROM domain),
(SELECT pg_database_size(current_database()));`)
return row.Scan(&stats.Npages, &stats.Ndomains, &stats.Indexbytes)
}); err != nil {
return nil, err
}