Przeglądaj źródła

fix: various fixes

master
Blaz Smehov 1 tydzień temu
rodzic
commit
a71e69ac3a
5 zmienionych plików z 5 dodań i 4 usunięć
  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 Wyświetl plik

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

// 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 {
a.DB.Create(&c)
a.DB.Clauses(clause.OnConflict{DoNothing: true}).Create(&c)
}
a.DB.Find(&configs)
for _, c := range configs {


+ 2
- 2
internal/pkg/service/beacon_service.go Wyświetl plik

@@ -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,


BIN
location Wyświetl plik


+ 1
- 1
scripts/config/settings.sh Wyświetl plik

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


BIN
server Wyświetl plik


Ładowanie…
Anuluj
Zapisz