Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
Update heartbeat monitors updated at time
Acho Arnold48eb63305667
diff --git a/api/pkg/entities/heartbeat_monitor.go b/api/pkg/entities/heartbeat_monitor.goindex 855e3be7..bc4e6b1f 100644--- a/api/pkg/entities/heartbeat_monitor.go+++ b/api/pkg/entities/heartbeat_monitor.go@@ -1,14 +1,18 @@package entitiesimport (+ "time"+"github.com/google/uuid")// HeartbeatMonitor is used to monitor heartbeats of a phonetype HeartbeatMonitor struct {- ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`- PhoneID uuid.UUID `json:"phone_id" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`- UserID UserID `json:"user_id" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`- QueueID string `json:"queue_id" example:"0360259236613675274"`- Owner string `json:"owner" example:"+18005550199"`+ ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`+ PhoneID uuid.UUID `json:"phone_id" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`+ UserID UserID `json:"user_id" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`+ QueueID string `json:"queue_id" example:"0360259236613675274"`+ Owner string `json:"owner" example:"+18005550199"`+ CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"`+ UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"`}diff --git a/api/pkg/repositories/gorm_heartbeat_monitor_repository.go b/api/pkg/repositories/gorm_heartbeat_monitor_repository.goindex fb7ded3b..716dc7e3 100644--- a/api/pkg/repositories/gorm_heartbeat_monitor_repository.go+++ b/api/pkg/repositories/gorm_heartbeat_monitor_repository.go@@ -3,6 +3,7 @@ package repositoriesimport ("context""fmt"+ "time""github.com/google/uuid"@@ -29,8 +30,10 @@ func (repository *gormHeartbeatMonitorRepository) UpdateQueueID(ctx context.Conterr := repository.db.Model(&entities.HeartbeatMonitor{}).Where("id = ?", monitorID).- UpdateColumn("queue_id", queueID).- Error+ Updates(map[string]any{+ "queue_id": queueID,+ "updated_at": time.Now().UTC(),+ }).Errorif err != nil {msg := fmt.Sprintf("cannot update heartbeat monitor ID [%s]", monitorID)return repository.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))@@ -73,11 +76,6 @@ func (repository *gormHeartbeatMonitorRepository) Index(ctx context.Context, usedefer span.End()query := repository.db.WithContext(ctx).Where("user_id = ?", userID).Where("owner = ?", owner)- if len(params.Query) > 0 {- queryPattern := "%" + params.Query + "%"- query.Where("quantity ILIKE ?", queryPattern)- }-heartbeats := new([]entities.Heartbeat)if err := query.Order("timestamp DESC").Limit(params.Limit).Offset(params.Skip).Find(&heartbeats).Error; err != nil {msg := fmt.Sprintf("cannot fetch heartbeats with owner [%s] and params [%+#v]", owner, params)diff --git a/api/pkg/services/heartbeat_service.go b/api/pkg/services/heartbeat_service.goindex 400d3f4f..18b86a73 100644--- a/api/pkg/services/heartbeat_service.go+++ b/api/pkg/services/heartbeat_service.go@@ -125,10 +125,12 @@ func (service *HeartbeatService) StoreMonitor(ctx context.Context, params *Heart}heartbeatMonitor := &entities.HeartbeatMonitor{- ID: uuid.New(),- PhoneID: params.PhoneID,- UserID: params.UserID,- Owner: params.Owner,+ ID: uuid.New(),+ PhoneID: params.PhoneID,+ UserID: params.UserID,+ Owner: params.Owner,+ CreatedAt: time.Now().UTC(),+ UpdatedAt: time.Now().UTC(),}if err = service.monitorRepository.Store(ctx, heartbeatMonitor); err != nil {