Skip to content

Commit

Permalink
style: Fix golangci lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
TimVosch committed Jan 7, 2025
1 parent d1a0762 commit 5d5c4dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
12 changes: 9 additions & 3 deletions services/core/measurements/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,21 @@ func (s *Service) StartMeasurementBatchStorer(interval time.Duration) cleanupper
for {
select {
case <-stop:
s.CommitBatch(false)
if err := s.CommitBatch(false); err != nil {
log.Printf("error committing batch: %s\n", err.Error())
}
break outer
case m := <-s.measurementBatchChan:
s.measurementBatch = append(s.measurementBatch, m)
if len(s.measurementBatch) == cap(s.measurementBatch) {
s.CommitBatch(false)
if err := s.CommitBatch(false); err != nil {
log.Printf("error committing batch: %s\n", err.Error())
}
}
case <-t.C:
s.CommitBatch(false)
if err := s.CommitBatch(false); err != nil {
log.Printf("error committing batch: %s\n", err.Error())
}
}
}
close(done)
Expand Down
6 changes: 3 additions & 3 deletions services/core/measurements/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func TestShouldCopyOverDefaultFields(t *testing.T) {
// Act
err = svc.ProcessPipelineMessage(msg)
require.NoError(t, err)
svc.CommitBatch(true)
assert.NoError(t, svc.CommitBatch(true))

// Assert
require.Len(t, store.calls.StoreMeasurements, 1, "StoreMeasurements should've been called")
Expand Down Expand Up @@ -334,7 +334,7 @@ func TestShouldChooseMeasurementLocationOverDeviceLocation(t *testing.T) {
require.NoError(t,
svc.ProcessPipelineMessage(msg),
)
svc.CommitBatch(true)
assert.NoError(t, svc.CommitBatch(true))

// Assert
require.Len(t, store.calls.StoreMeasurements, 1, "StoreMeasurements should've been called")
Expand Down Expand Up @@ -414,7 +414,7 @@ func TestShouldSetExpirationDate(t *testing.T) {
// Act
err = svc.ProcessPipelineMessage(msg)
require.NoError(t, err)
svc.CommitBatch(true)
assert.NoError(t, svc.CommitBatch(true))

// Assert
require.Len(t, store.calls.StoreMeasurements, 1, "StoreMeasurements should've been called")
Expand Down
19 changes: 0 additions & 19 deletions services/core/measurements/datastreams.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,3 @@ type Datastream struct {
CreatedAt time.Time `json:"created_at" db:"created_at"`
TenantID int64 `json:"-"`
}

func newDatastream(tenantID, sensorID int64, obs, uom string) (*Datastream, error) {
// TODO: Check UoM conforms to UCUM
if uom == "" || false {
return nil, ErrUoMInvalid
}
if sensorID == 0 {
return nil, ErrInvalidSensorID
}
return &Datastream{
ID: uuid.New(),
TenantID: tenantID,
Description: "",
SensorID: sensorID,
ObservedProperty: obs,
UnitOfMeasurement: uom,
CreatedAt: time.Now(),
}, nil
}

0 comments on commit 5d5c4dd

Please sign in to comment.