Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more data to output of collStats and dbStats #3538

Merged
merged 32 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6d00a16
include capped collection details in response
chilagrow Oct 10, 2023
9902948
unskip collstats for new pg backend
chilagrow Oct 10, 2023
1c7aafe
unskip datasize test
chilagrow Oct 10, 2023
e4de4c3
add compat test for testing capped collection in collstats
chilagrow Oct 10, 2023
6667680
increase delta
chilagrow Oct 10, 2023
0854b7e
update how collstats results are compared
chilagrow Oct 10, 2023
f57581f
Merge branch 'main' into issue-2447-collstats-more-data
chilagrow Oct 11, 2023
a31f3e4
update expectation for collstats
chilagrow Oct 11, 2023
98bd5e5
skip test for old pg
chilagrow Oct 11, 2023
68bb0a2
Revert "update expectation for collstats"
chilagrow Oct 11, 2023
47611b4
Revert "skip test for old pg"
chilagrow Oct 11, 2023
176c254
Revert "update how collstats results are compared"
chilagrow Oct 11, 2023
e70f2df
add todo
chilagrow Oct 11, 2023
10b8bbd
add tests and todos
chilagrow Oct 12, 2023
0bb475c
lint
chilagrow Oct 12, 2023
e88eb6d
update test
chilagrow Oct 12, 2023
df97d37
Merge branch 'main' into issue-2447-collstats-more-data
chilagrow Oct 12, 2023
d7276de
revert change
chilagrow Oct 12, 2023
21ee1f4
merge conflict
chilagrow Oct 13, 2023
90a3622
usage of options in test
chilagrow Oct 13, 2023
4a5e4eb
rename
chilagrow Oct 13, 2023
4847e83
capped information is fetched from list collection
chilagrow Oct 13, 2023
9032ee4
dbstats uses countdocument too
chilagrow Oct 13, 2023
7695485
remove collection count from stats
chilagrow Oct 13, 2023
9302c6d
Merge branch 'main' into issue-2447-collstats-more-data
chilagrow Oct 15, 2023
160854a
cleanup
chilagrow Oct 16, 2023
4c92c09
remove CountIndexes from CollStats and DBStats
chilagrow Oct 16, 2023
d0f3022
remove todo
chilagrow Oct 16, 2023
58753c4
update comment, undo unwanted change
chilagrow Oct 16, 2023
cd70518
lint
chilagrow Oct 16, 2023
f85bc75
add missed commit
chilagrow Oct 16, 2023
cfda6e0
Merge branch 'main' into issue-2447-collstats-more-data
AlekSi Oct 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove collection count from stats
  • Loading branch information
chilagrow committed Oct 13, 2023
commit 7695485b4a4ee885b760cfe9d05b9b5076c856b8
11 changes: 5 additions & 6 deletions internal/backends/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,11 @@ type DatabaseStatsParams struct {
//
// TODO https://github.com/FerretDB/FerretDB/issues/2447
type DatabaseStatsResult struct {
CountCollections int64
CountDocuments int64
CountIndexes int64
SizeTotal int64
SizeIndexes int64
SizeCollections int64
CountDocuments int64
CountIndexes int64
SizeTotal int64
SizeIndexes int64
SizeCollections int64
}

// Stats returns statistics about the database.
Expand Down
11 changes: 5 additions & 6 deletions internal/backends/postgresql/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,11 @@ func (db *database) Stats(ctx context.Context, params *backends.DatabaseStatsPar
}

return &backends.DatabaseStatsResult{
CountCollections: int64(len(list)),
CountDocuments: stats.countRows,
CountIndexes: stats.countIndexes,
SizeTotal: *schemaSize,
SizeIndexes: stats.sizeIndexes,
SizeCollections: stats.sizeTables,
CountDocuments: stats.countRows,
CountIndexes: stats.countIndexes,
SizeTotal: *schemaSize,
SizeIndexes: stats.sizeIndexes,
SizeCollections: stats.sizeTables,
}, nil
}

Expand Down
2 changes: 0 additions & 2 deletions internal/backends/postgresql/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func TestDatabaseStats(t *testing.T) {
res, err := db.Stats(ctx, new(backends.DatabaseStatsParams))
require.NoError(t, err)
require.NotZero(t, res.SizeTotal)
require.Equal(t, res.CountCollections, int64(len(cNames)))
require.Zero(t, res.SizeCollections)
require.Zero(t, res.CountDocuments)
require.NotZero(t, res.CountIndexes)
Expand All @@ -87,7 +86,6 @@ func TestDatabaseStats(t *testing.T) {
res, err := db.Stats(ctx, new(backends.DatabaseStatsParams))
require.NoError(t, err)
require.NotZero(t, res.SizeTotal)
require.Equal(t, res.CountCollections, int64(len(cNames)))
require.NotZero(t, res.SizeCollections)
require.Equal(t, int64(1), res.CountDocuments)
require.NotZero(t, res.CountIndexes)
Expand Down
11 changes: 5 additions & 6 deletions internal/backends/sqlite/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,11 @@ func (db *database) Stats(ctx context.Context, params *backends.DatabaseStatsPar
}

return &backends.DatabaseStatsResult{
CountCollections: int64(len(list)),
CountDocuments: stats.countRows,
CountIndexes: stats.countIndexes,
SizeTotal: totalSize,
SizeIndexes: stats.sizeIndexes,
SizeCollections: stats.sizeTables,
CountDocuments: stats.countRows,
CountIndexes: stats.countIndexes,
SizeTotal: totalSize,
SizeIndexes: stats.sizeIndexes,
SizeCollections: stats.sizeTables,
}, nil
}

Expand Down
1 change: 0 additions & 1 deletion internal/backends/sqlite/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func TestDatabaseStats(t *testing.T) {
res, err := db.Stats(ctx, new(backends.DatabaseStatsParams))
require.NoError(t, err)
require.NotZero(t, res.SizeTotal)
require.Equal(t, res.CountCollections, int64(len(cNames)))
require.NotZero(t, res.SizeCollections)
require.Zero(t, res.CountDocuments)
})
Expand Down
7 changes: 6 additions & 1 deletion internal/handlers/sqlite/msg_dbstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
return nil, lazyerrors.Error(err)
}

list, err := db.ListCollections(ctx, new(backends.ListCollectionsParams))
if err != nil {
return nil, lazyerrors.Error(err)
}

Check warning on line 67 in internal/handlers/sqlite/msg_dbstats.go

View check run for this annotation

Codecov / codecov/patch

internal/handlers/sqlite/msg_dbstats.go#L66-L67

Added lines #L66 - L67 were not covered by tests

stats, err := db.Stats(ctx, new(backends.DatabaseStatsParams))
if backends.ErrorCodeIs(err, backends.ErrorCodeDatabaseDoesNotExist) {
stats = new(backends.DatabaseStatsResult)
Expand All @@ -75,7 +80,7 @@
// FerretDB always returns int64 for simplicity.
pairs := []any{
"db", dbName,
"collections", stats.CountCollections,
"collections", int64(len(list.Collections)),
// TODO https://github.com/FerretDB/FerretDB/issues/176
"views", int32(0),
"objects", stats.CountDocuments,
Expand Down
Loading