|
|
|
@@ -151,9 +151,9 @@ func LocationToBeaconServiceAI(msg model.HTTPLocation, db *gorm.DB, writer *kafk |
|
|
|
|
|
|
|
func SendAlert(trackerId, alertType string, writer *kafka.Writer, ctx context.Context, db *gorm.DB) { |
|
|
|
var existingAlert model.Alert |
|
|
|
result := db.Select("status").Where("tracker_id = ? AND type = ?", trackerId, alertType).Order("timestamp DESC").First(&existingAlert) |
|
|
|
result := db.Select("status").Where("tracker_id = ? AND type = ?", trackerId, alertType).Order("timestamp DESC").Limit(1).Find(&existingAlert) |
|
|
|
|
|
|
|
if result.Error == gorm.ErrRecordNotFound || existingAlert.Status == "resolved" { |
|
|
|
if result.RowsAffected == 0 || existingAlert.Status == "resolved" { |
|
|
|
alert := model.Alert{ |
|
|
|
ID: uuid.New().String(), |
|
|
|
TrackerID: trackerId, |
|
|
|
|