| @@ -54,6 +54,21 @@ func GetTrackerZones(token string, client *http.Client, cfg *config.Config) ([]m | |||||
| return i, nil | 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) { | func GetZones(token string, client *http.Client, cfg *config.Config) ([]model.Zone, error) { | ||||
| res, err := getRequest(token, "getZones", client, cfg) | res, err := getRequest(token, "getZones", client, cfg) | ||||
| if err != nil { | if err != nil { | ||||
| @@ -52,6 +52,10 @@ func UpdateDB(db *gorm.DB, ctx context.Context, cfg *config.Config, writer *kafk | |||||
| syncTable(db, gateways) | syncTable(db, gateways) | ||||
| } | } | ||||
| if floors, err := GetFloors(token, client, cfg); err == nil { | |||||
| syncTable(db, floors) | |||||
| } | |||||
| if zones, err := GetZones(token, client, cfg); err == nil { | if zones, err := GetZones(token, client, cfg); err == nil { | ||||
| syncTable(db, zones) | syncTable(db, zones) | ||||
| } | } | ||||
| @@ -1,11 +1,11 @@ | |||||
| package model | package model | ||||
| type Floor struct { | 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"` | |||||
| } | } | ||||
| @@ -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": "ai", | |||||
| "current_algorithm": "filter", | |||||
| "last_seen_threshold": 310, | "last_seen_threshold": 310, | ||||
| "beacon_metric_size": 100, | "beacon_metric_size": 100, | ||||
| "HA_send_interval": 60, | "HA_send_interval": 60, | ||||