Ver a proveniência

fix: various fixes

master
Blaz Smehov há 1 semana
ascendente
cometimento
a71e69ac3a
5 ficheiros alterados com 5 adições e 4 eliminações
  1. +2
    -1
      internal/app/server/app.go
  2. +2
    -2
      internal/pkg/service/beacon_service.go
  3. BIN
      location
  4. +1
    -1
      scripts/config/settings.sh
  5. BIN
      server

+ 2
- 1
internal/app/server/app.go Ver ficheiro

@@ -19,6 +19,7 @@ import (
"github.com/AFASystems/presence/internal/pkg/model" "github.com/AFASystems/presence/internal/pkg/model"
"github.com/AFASystems/presence/internal/pkg/service" "github.com/AFASystems/presence/internal/pkg/service"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/clause"
) )


// ServerApp holds dependencies and state for the server service. // ServerApp holds dependencies and state for the server service.
@@ -87,7 +88,7 @@ func (a *ServerApp) Init(ctx context.Context) error {
} }


for _, c := range configs { for _, c := range configs {
a.DB.Create(&c)
a.DB.Clauses(clause.OnConflict{DoNothing: true}).Create(&c)
} }
a.DB.Find(&configs) a.DB.Find(&configs)
for _, c := range configs { for _, c := range configs {


+ 2
- 2
internal/pkg/service/beacon_service.go Ver ficheiro

@@ -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) { func SendAlert(trackerId, alertType string, writer *kafka.Writer, ctx context.Context, db *gorm.DB) {
var existingAlert model.Alert 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{ alert := model.Alert{
ID: uuid.New().String(), ID: uuid.New().String(),
TrackerID: trackerId, TrackerID: trackerId,


BIN
location Ver ficheiro


+ 1
- 1
scripts/config/settings.sh Ver ficheiro

@@ -7,7 +7,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
curl -s -X PATCH "${BASE_URL}/reslevis/settings" \ curl -s -X PATCH "${BASE_URL}/reslevis/settings" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{ -d '{
"current_algorithm": "filter",
"current_algorithm": "ai",
"last_seen_threshold": 310, "last_seen_threshold": 310,
"beacon_metric_size": 100, "beacon_metric_size": 100,
"HA_send_interval": 60, "HA_send_interval": 60,


BIN
server Ver ficheiro


Carregando…
Cancelar
Guardar