forked from simrail/simrail.pro
feat(): sort active players
This commit is contained in:
parent
e84afd359a
commit
3f3e369fb7
@ -40,6 +40,16 @@ interface ActiveStation
|
||||
steam: string;
|
||||
}
|
||||
|
||||
const sortFunction = (a: ActiveStation | ActiveTrain, b: ActiveStation | ActiveTrain) => {
|
||||
if (a.server.includes('pl') && !b.server.includes('pl'))
|
||||
return -1;
|
||||
|
||||
if (!a.server.includes('pl') && b.server.includes('pl'))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
export class ActivePlayersRoute
|
||||
{
|
||||
static load()
|
||||
@ -74,7 +84,8 @@ export class ActivePlayersRoute
|
||||
a = a.filter(d => s.filter(c => c.test(d.server) || c.test(d.username) || c.test(d.steam) || c.test(d.steam) || c.test(d.trainName) || c.test(d.trainNumber)).length === s.length);
|
||||
}
|
||||
|
||||
a = arrayGroupBy(a, d => d.server);
|
||||
a = arrayGroupBy(a, d => d.server)
|
||||
.sort(sortFunction);
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
@ -115,7 +126,9 @@ export class ActivePlayersRoute
|
||||
}
|
||||
|
||||
|
||||
a = arrayGroupBy(a, d => d.server);
|
||||
|
||||
a = arrayGroupBy(a, d => d.server)
|
||||
.sort(sortFunction);
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
|
Loading…
x
Reference in New Issue
Block a user