Просмотр исходного кода

fix: floors are now persisted in the db

master
Blaz Smehov 1 неделю назад
Родитель
Сommit
355a0c9b52
8 измененных файлов: 27 добавлений и 8 удалений
  1. Двоичные данные
      bridge
  2. Двоичные данные
      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. Двоичные данные
      location
  7. +1
    -1
      scripts/config/settings.sh
  8. Двоичные данные
      server

Двоичные данные
bridge Просмотреть файл


Двоичные данные
decoder Просмотреть файл


+ 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"`
}

Двоичные данные
location Просмотреть файл


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


Двоичные данные
server Просмотреть файл


Загрузка…
Отмена
Сохранить