RangeToLocalSet returns a set of devices that have data in the registry.
(ctx context.Context)
| 32 | |
| 33 | // RangeToLocalSet returns a set of devices that have data in the registry. |
| 34 | func (cleaner *RegistryCleaner) RangeToLocalSet(ctx context.Context) error { |
| 35 | cleaner.LocalDeviceSet = make(map[string]struct{}) |
| 36 | cleaner.LocalApplicationSet = make(map[string]struct{}) |
| 37 | err := cleaner.DevRegistry.RangeByID(ctx, []string{"ids"}, func(ctx context.Context, ids *ttnpb.EndDeviceIdentifiers, dev *ttnpb.EndDevice) bool { |
| 38 | cleaner.LocalDeviceSet[unique.ID(ctx, ids)] = struct{}{} |
| 39 | return true |
| 40 | }) |
| 41 | if err != nil { |
| 42 | return err |
| 43 | } |
| 44 | return cleaner.AppAsRegistry.Range(ctx, []string{"application_server_id"}, func(ctx context.Context, ids *ttnpb.ApplicationIdentifiers, _ *ttnpb.ApplicationActivationSettings) bool { |
| 45 | cleaner.LocalApplicationSet[unique.ID(ctx, ids)] = struct{}{} |
| 46 | return true |
| 47 | }) |
| 48 | } |
| 49 | |
| 50 | // DeleteApplicationAndDeviceData deletes registry application data of all devices in the device id list. |
| 51 | func (cleaner *RegistryCleaner) DeleteApplicationAndDeviceData(ctx context.Context, deviceList, applicationList []string) error { |