Skip to content

Commit

Permalink
fix duplicating models
Browse files Browse the repository at this point in the history
  • Loading branch information
vsimakhin committed Jan 22, 2024
1 parent 86292a6 commit b29c10b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Fix: Duplicate models in the field of the flight record form. Fixed. Plus added sorting for models and regs.
- Fix: The ICAO code was not properly set for the airports from ourairports.com source. Changed the algorithm to assign the codes.

## [2.29.1] - 15.01.2024
Expand Down
11 changes: 9 additions & 2 deletions cmd/web/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,17 @@ func (app *application) lastRegsAndModels() (aircraftRegs []string, aircraftMode
}

for key, val := range lastAircrafts {
aircraftRegs = append(aircraftRegs, key)
aircraftModels = append(aircraftModels, val)
if !slices.Contains(aircraftRegs, key) {
aircraftRegs = append(aircraftRegs, key)
}
if !slices.Contains(aircraftModels, val) {
aircraftModels = append(aircraftModels, val)
}
}

slices.Sort(aircraftRegs)
slices.Sort(aircraftModels)

return aircraftRegs, aircraftModels
}

Expand Down

0 comments on commit b29c10b

Please sign in to comment.