From b29c10b8b4b6612e082c1de0f5e4b413f19a7ebd Mon Sep 17 00:00:00 2001 From: Vladimir Simakhin Date: Mon, 22 Jan 2024 15:19:21 +0100 Subject: [PATCH] fix duplicating models --- CHANGELOG.md | 1 + cmd/web/helpers.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b24cfe3..98ebbf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cmd/web/helpers.go b/cmd/web/helpers.go index bbc44c5..1fc5aa2 100644 --- a/cmd/web/helpers.go +++ b/cmd/web/helpers.go @@ -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 }