Anonymous Access: Pagination for devices (#80028)
* first commit * add: pagination to anondevices * fmt * swagger and tests * swagger * testing out test * fixing tests * made it possible to query for from and to time * refactor: change to query for ip adress instead * fix: tests
This commit is contained in:
@@ -154,6 +154,7 @@ func (a *AnonDeviceService) TagDevice(ctx context.Context, httpReq *http.Request
|
||||
// ListDevices returns all devices that have been updated between the given times.
|
||||
func (a *AnonDeviceService) ListDevices(ctx context.Context, from *time.Time, to *time.Time) ([]*anonstore.Device, error) {
|
||||
if !a.cfg.AnonymousEnabled {
|
||||
a.log.Debug("Anonymous access is disabled, returning empty result")
|
||||
return []*anonstore.Device{}, nil
|
||||
}
|
||||
|
||||
@@ -163,12 +164,21 @@ func (a *AnonDeviceService) ListDevices(ctx context.Context, from *time.Time, to
|
||||
// CountDevices returns the number of devices that have been updated between the given times.
|
||||
func (a *AnonDeviceService) CountDevices(ctx context.Context, from time.Time, to time.Time) (int64, error) {
|
||||
if !a.cfg.AnonymousEnabled {
|
||||
a.log.Debug("Anonymous access is disabled, returning empty result")
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
return a.anonStore.CountDevices(ctx, from, to)
|
||||
}
|
||||
|
||||
func (a *AnonDeviceService) SearchDevices(ctx context.Context, query *anonstore.SearchDeviceQuery) (*anonstore.SearchDeviceQueryResult, error) {
|
||||
if !a.cfg.AnonymousEnabled {
|
||||
a.log.Debug("Anonymous access is disabled, returning empty result")
|
||||
return nil, nil
|
||||
}
|
||||
return a.anonStore.SearchDevices(ctx, query)
|
||||
}
|
||||
|
||||
func (a *AnonDeviceService) Run(ctx context.Context) error {
|
||||
ticker := time.NewTicker(2 * time.Hour)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user