From dae705ccbc10d3015cc3b67054c5eee032b4ead7 Mon Sep 17 00:00:00 2001 From: Adam Wisher <37659188+mrwish7@users.noreply.github.com> Date: Sat, 31 May 2025 14:38:07 +0100 Subject: [PATCH] Limit multiple matches Only return a max of 10 extra TX matches and filter any with a score less than 1/10 of the winner --- server/tx_search.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/tx_search.js b/server/tx_search.js index 33c8eef..e17c850 100644 --- a/server/tx_search.js +++ b/server/tx_search.js @@ -191,9 +191,13 @@ async function fetchTx(freq, piCode, rdsPs) { for (loc of filteredLocations) { loc.score = evaluateStation(loc); } + // Sort by score in descending order filteredLocations.sort((a, b) => b.score - a.score); match = filteredLocations[0]; - multiMatches = filteredLocations.slice(1); + // Have a maximum of 10 extra matches and remove any with less than 1/10 of the winning score + multiMatches = filteredLocations + .slice(1, 11) + .filter(obj => obj.score >= (match.score/10)); } else if (filteredLocations.length === 1) { match = filteredLocations[0]; match.score = 1;