From 92640d1ad0901ae6549121bdb2d8d27a211e6c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20P=C3=A9rez?= Date: Thu, 9 Oct 2025 16:56:23 +0200 Subject: [PATCH] read all sensors implemented --- internal/domains/sensors/repository.go | 9 ++++++++- internal/domains/sensors/service.go | 5 +---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/domains/sensors/repository.go b/internal/domains/sensors/repository.go index e57e9cd..6065fb2 100644 --- a/internal/domains/sensors/repository.go +++ b/internal/domains/sensors/repository.go @@ -116,7 +116,14 @@ func (i *inMemory) ReadSensorValues(sensorID string, from time.Time, to time.Tim } func (i *inMemory) ReadAllSensors() ([]Sensor, error) { - panic("unimplemented") + i.mu.Lock() + defer i.mu.Unlock() + + sensors := make([]Sensor, 0, len(i.sensors)) + for _, s := range i.sensors { + sensors = append(sensors, *s) + } + return sensors, nil } type DecoratorRepo struct { diff --git a/internal/domains/sensors/service.go b/internal/domains/sensors/service.go index 0044712..365861c 100644 --- a/internal/domains/sensors/service.go +++ b/internal/domains/sensors/service.go @@ -48,8 +48,5 @@ func (s *Service) GetValues(sensorID string, from, to time.Time) (Sensor, error) } func (s *Service) ListSensors() ([]Sensor, error) { - - s.repo.ReadAllSensors() - - return []Sensor{}, nil + return s.repo.ReadAllSensors() }