mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: clean up usage of Object.keys (#14484)
This commit is contained in:
@@ -233,21 +233,9 @@ const selectByLatency = (
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const proxyMap = proxies.reduce(
|
||||
(acc, proxy) => {
|
||||
acc[proxy.id] = proxy;
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, Region>,
|
||||
);
|
||||
|
||||
const best = Object.keys(latencies)
|
||||
.map((proxyId) => {
|
||||
return {
|
||||
id: proxyId,
|
||||
...latencies[proxyId],
|
||||
};
|
||||
})
|
||||
const proxyMap = Object.fromEntries(proxies.map((it) => [it.id, it]));
|
||||
const best = Object.entries(latencies)
|
||||
.map(([proxyId, latency]) => ({ id: proxyId, ...latency }))
|
||||
// If the proxy is not in our list, or it is unhealthy, ignore it.
|
||||
.filter((latency) => proxyMap[latency.id]?.healthy)
|
||||
.sort((a, b) => a.latencyMS - b.latencyMS)
|
||||
|
||||
Reference in New Issue
Block a user