Skip to content

Commit

Permalink
fix infinite loop problem
Browse files Browse the repository at this point in the history
  • Loading branch information
zodiac1214 committed Jan 4, 2024
1 parent 5c2cf47 commit c25c93d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apps/core/services/xplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,11 @@ func (s xplaneService) setupWebsocket() {
var lastSyncedFlightStatus models.FlightStatus
lastSyncedId, _ := strconv.ParseUint(req, 10, 0)
s.db.Model(&models.FlightStatus{}).
Where("arrival_total_weight > 1").
Where("arrival_total_weight > 10").
Order("id desc").
Limit(1).
Find(&lastSyncedFlightStatus)
s.Logger.Infof("lastSyncedFlightStatus: %+v", lastSyncedFlightStatus)
if lastSyncedFlightStatus.ID == uint(lastSyncedId) {
s.Logger.Infof("Synced flight logs for client")
err := ws.WriteMessage(websocket.TextMessage, []byte("SyncFlightLogs|Done"))
Expand All @@ -219,7 +220,7 @@ func (s xplaneService) setupWebsocket() {
s.db.Preload("Locations").
Preload("Events").
Model(&models.FlightStatus{}).
Where("id > ?", lastSyncedId).
Where("id > ? AND arrival_total_weight > 10", lastSyncedId).
Order("id asc").
Limit(5).
Find(&res)
Expand Down

0 comments on commit c25c93d

Please sign in to comment.