| Аутор | SHA1 | Порука | Датум |
|---|---|---|---|
|
|
020064ddb0 | feat: read zone ids from tracker table | пре 1 месец |
|
|
85ca2e7360 | chore: update gitignore | пре 1 месец |
| @@ -28,4 +28,7 @@ main | |||||
| *.sh | *.sh | ||||
| **/*.log | |||||
| **/*.log | |||||
| ROADMAP.md | |||||
| docs/architectural-concerns.md | |||||
| @@ -109,7 +109,6 @@ func decodeBeacon(adv model.BeaconAdvertisement, appState *appcontext.AppState, | |||||
| } | } | ||||
| eMsg, err := event.ToJSON() | eMsg, err := event.ToJSON() | ||||
| fmt.Printf("event: %+v\n", eMsg) | |||||
| if err != nil { | if err != nil { | ||||
| return err | return err | ||||
| } | } | ||||
| @@ -130,12 +130,22 @@ eventLoop: | |||||
| case <-ctx.Done(): | case <-ctx.Done(): | ||||
| break eventLoop | break eventLoop | ||||
| case msg := <-chLoc: | case msg := <-chLoc: | ||||
| if msg.ID == "" { | |||||
| fmt.Println("Received message with empty ID, skipping...") | |||||
| continue | |||||
| } | |||||
| id := msg.ID | id := msg.ID | ||||
| fmt.Println("id: ", id) | |||||
| if err := db.First(&model.Tracker{}, "id = ?", id).Error; err != nil { | if err := db.First(&model.Tracker{}, "id = ?", id).Error; err != nil { | ||||
| fmt.Printf("Location event for untracked beacon: %s\n", id) | fmt.Printf("Location event for untracked beacon: %s\n", id) | ||||
| continue | continue | ||||
| } | } | ||||
| var results []model.TrackerZones | |||||
| db.Where("tracker = ?", id).Find(&results) | |||||
| fmt.Printf("%v", results) | |||||
| if err := db.Updates(&model.Tracker{ID: id, Location: msg.Location, Distance: msg.Distance}).Error; err != nil { | if err := db.Updates(&model.Tracker{ID: id, Location: msg.Location, Distance: msg.Distance}).Error; err != nil { | ||||
| fmt.Println("Error in saving distance for beacon: ", err) | fmt.Println("Error in saving distance for beacon: ", err) | ||||
| continue | continue | ||||
| @@ -9,7 +9,6 @@ import ( | |||||
| "gorm.io/gorm" | "gorm.io/gorm" | ||||
| ) | ) | ||||
| // controller/tracker_controller.go | |||||
| func TrackerZoneAddController(db *gorm.DB) http.HandlerFunc { | func TrackerZoneAddController(db *gorm.DB) http.HandlerFunc { | ||||
| return func(w http.ResponseWriter, r *http.Request) { | return func(w http.ResponseWriter, r *http.Request) { | ||||
| var tz model.TrackerZones | var tz model.TrackerZones | ||||
| @@ -3,7 +3,7 @@ package model | |||||
| type TrackerZones struct { | type TrackerZones struct { | ||||
| ID string `json:"id" gorm:"primaryKey"` | ID string `json:"id" gorm:"primaryKey"` | ||||
| ZoneList []string `json:"zoneList" gorm:"serializer:json"` | ZoneList []string `json:"zoneList" gorm:"serializer:json"` | ||||
| Tracker string `json:"tracker"` | |||||
| Tracker string `json:"tracker" gorm:"index"` | |||||
| Days string `json:"days"` | Days string `json:"days"` | ||||
| Time string `json:"time"` | Time string `json:"time"` | ||||
| } | } | ||||