You've already forked fm-dx-webserver
mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-02-27 14:33:52 +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:
@@ -191,9 +191,13 @@ async function fetchTx(freq, piCode, rdsPs) {
|
|||||||
for (loc of filteredLocations) {
|
for (loc of filteredLocations) {
|
||||||
loc.score = evaluateStation(loc);
|
loc.score = evaluateStation(loc);
|
||||||
}
|
}
|
||||||
|
// Sort by score in descending order
|
||||||
filteredLocations.sort((a, b) => b.score - a.score);
|
filteredLocations.sort((a, b) => b.score - a.score);
|
||||||
match = filteredLocations[0];
|
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) {
|
} else if (filteredLocations.length === 1) {
|
||||||
match = filteredLocations[0];
|
match = filteredLocations[0];
|
||||||
match.score = 1;
|
match.score = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user