1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

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
This commit is contained in:
Adam Wisher
2025-05-31 14:38:07 +01:00
parent c9fd4915b8
commit dae705ccbc

View File

@@ -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;