Split frontend and backend

This commit is contained in:
2020-05-30 17:59:40 +02:00
parent 22e31b51dc
commit 42b558254f
42 changed files with 11604 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import TableEntry from "../models/TableEntry";
import TunaKillUser from "../models/TunaKillUser";
class SinusBotService {
public static consumeTunakillResponse(data: any): TableEntry[] | undefined {
if (!(data !== null || data[0] !== null || data[0].data !== null)) {
return undefined;
}
const response = data[0].data;
if (!(response.length > 0)) {
return undefined;
}
return response
.map((user: TunaKillUser) => {
if (user.name === "Server Query Admin") { return null; }
return {
name: user.name,
rawTime: user.time,
onlineTime: new Date(user.time * 1000)
.toISOString()
.substr(11, 8)
};
})
.sort((a: any, b: any) => {
if (a.rawTime < b.rawTime) {
return -1;
}
if (a.rawTime > b.rawTime) {
return 1;
}
return 0;
});
}
}
export default SinusBotService;