Преглед изворни кода

fix: floors are now persisted in the db

master
Blaz Smehov пре 1 недеља
родитељ
комит
355a0c9b52
8 измењених фајлова са 27 додато и 8 уклоњено
  1. BIN
      bridge
  2. BIN
      decoder
  3. +15
    -0
      internal/pkg/apiclient/data.go
  4. +4
    -0
      internal/pkg/apiclient/updatedb.go
  5. +7
    -7
      internal/pkg/model/floor.go
  6. BIN
      location
  7. +1
    -1
      scripts/config/settings.sh
  8. BIN
      server


+ 15
- 0
internal/pkg/apiclient/data.go Прегледај датотеку

@@ -54,6 +54,21 @@ func GetTrackerZones(token string, client *http.Client, cfg *config.Config) ([]m
return i, nil
}

func GetFloors(token string, client *http.Client, cfg *config.Config) ([]model.Floor, error) {
res, err := getRequest(token, "getFloors", client, cfg)
if err != nil {
return []model.Floor{}, err
}

var i []model.Floor
err = json.NewDecoder(res.Body).Decode(&i)
if err != nil {
return []model.Floor{}, err
}

return i, nil
}

func GetZones(token string, client *http.Client, cfg *config.Config) ([]model.Zone, error) {
res, err := getRequest(token, "getZones", client, cfg)
if err != nil {


+ 4
- 0
internal/pkg/apiclient/updatedb.go Прегледај датотеку

@@ -52,6 +52,10 @@ func UpdateDB(db *gorm.DB, ctx context.Context, cfg *config.Config, writer *kafk
syncTable(db, gateways)
}

if floors, err := GetFloors(token, client, cfg); err == nil {
syncTable(db, floors)
}

if zones, err := GetZones(token, client, cfg); err == nil {
syncTable(db, zones)
}


+ 7
- 7
internal/pkg/model/floor.go Прегледај датотеку

@@ -1,11 +1,11 @@
package model

type Floor struct {
ID string `gorm:"unique;primaryKey"`
Name string `json:"name"`
FloorNumber int `json:"floornumber"`
Image string `json:"image"`
Description string `json:"description"`
Scale int `json:"scale"`
Building string `json:"building"`
ID string `gorm:"unique;primaryKey"`
Name string `json:"name"`
FloorNumber int `json:"floornumber"`
Image string `json:"image"`
Description string `json:"description"`
Scale float32 `json:"scale"`
Building string `json:"building"`
}


+ 1
- 1
scripts/config/settings.sh Прегледај датотеку

@@ -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": "ai",
"current_algorithm": "filter",
"last_seen_threshold": 310,
"beacon_metric_size": 100,
"HA_send_interval": 60,



Loading…
Откажи
Сачувај