Skip to content

Commit

Permalink
Merge pull request #182 from vsimakhin/fix/178-duplicate-models-in-th…
Browse files Browse the repository at this point in the history
…e-field-of-the-flight-record-form

fix duplicating models
  • Loading branch information
vsimakhin authored Jan 22, 2024
2 parents 86292a6 + b29c10b commit 71c44da
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 71c44da

Please sign in to comment.