mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* Add anonymous stats and user table - anonymous users users page - add feature toggle `anonymousAccess` - remove check for enterprise for `Device-Id` header in request - add anonusers/device count to stats * promise all, review comments * make use of promise all settled * refactoring: devices instead of users * review comments, moved countdevices to httpserver * fakeAnonService for tests and generate openapi spec * do not commit openapi3 and api-merged * add openapi * Apply suggestions from code review Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> * formatin * precise anon devices to avoid confusion --------- Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> Co-authored-by: jguer <me@jguer.space>
46 lines
1.6 KiB
Go
46 lines
1.6 KiB
Go
package statstest
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/services/stats"
|
|
)
|
|
|
|
type FakeService struct {
|
|
ExpectedAdminStats *stats.AdminStats
|
|
ExpectedSystemStats *stats.SystemStats
|
|
ExpectedDataSourceStats []*stats.DataSourceStats
|
|
ExpectedDataSourcesAccessStats []*stats.DataSourceAccessStats
|
|
ExpectedNotifierUsageStats []*stats.NotifierUsageStats
|
|
|
|
ExpectedError error
|
|
}
|
|
|
|
func NewFakeService() *FakeService {
|
|
return &FakeService{}
|
|
}
|
|
|
|
func (s *FakeService) GetAdminStats(ctx context.Context, query *stats.GetAdminStatsQuery) (*stats.AdminStats, error) {
|
|
return s.ExpectedAdminStats, s.ExpectedError
|
|
}
|
|
|
|
func (s *FakeService) GetAlertNotifiersUsageStats(ctx context.Context, query *stats.GetAlertNotifierUsageStatsQuery) ([]*stats.NotifierUsageStats, error) {
|
|
return s.ExpectedNotifierUsageStats, s.ExpectedError
|
|
}
|
|
|
|
func (s *FakeService) GetDataSourceStats(ctx context.Context, query *stats.GetDataSourceStatsQuery) ([]*stats.DataSourceStats, error) {
|
|
return s.ExpectedDataSourceStats, s.ExpectedError
|
|
}
|
|
|
|
func (s *FakeService) GetDataSourceAccessStats(ctx context.Context, query *stats.GetDataSourceAccessStatsQuery) ([]*stats.DataSourceAccessStats, error) {
|
|
return s.ExpectedDataSourcesAccessStats, s.ExpectedError
|
|
}
|
|
|
|
func (s *FakeService) GetSystemStats(ctx context.Context, query *stats.GetSystemStatsQuery) (*stats.SystemStats, error) {
|
|
return s.ExpectedSystemStats, s.ExpectedError
|
|
}
|
|
|
|
func (s *FakeService) GetSystemUserCountStats(ctx context.Context, query *stats.GetSystemUserCountStatsQuery) (*stats.SystemUserCountStats, error) {
|
|
return nil, s.ExpectedError
|
|
}
|