I'm unsure what I'm doing...

This commit is contained in:
furo 2021-11-01 01:05:37 +01:00
parent fcc6a19903
commit b3548cfee7
2 changed files with 35 additions and 29 deletions

2
.gitignore vendored
View File

@ -122,4 +122,4 @@ pnpm-lock.yaml
*.sql* *.sql*
players.msgpack players.msgpack
.env .env
ddnss/build ddnss/

View File

@ -14,8 +14,14 @@ export async function ddnssStart() {
for (const server of servers) { for (const server of servers) {
const connection = `${server.ip}:${server.port}` const connection = `${server.ip}:${server.port}`
if (!(server.num_clients > 0 && server.num_clients < (server.max_clients - 2))) if (!(server.num_clients > 0 && server.num_clients < (server.max_clients - 2))) {
return log(`Server (essentially) full! >> ${server.ip}:${server.port} -> ${server.num_clients}/${server.max_clients} clients`) log(`Server (essentially) full! >> ${connection} -> ${server.num_clients}/${server.max_clients} clients`)
continue
}
if(server.password) {
log(`Server is locked >> ${connection}`)
continue
}
log(`Connecting to server >> ${connection}`) log(`Connecting to server >> ${connection}`)
await scrapeServer(`${connection}`) await scrapeServer(`${connection}`)
@ -39,36 +45,36 @@ function scrapeServer(server) {
} }
const currentTime = Date.now() const currentTime = Date.now()
// TODO: Store statement once and reuse same statment. (whatever that means)
for (const entry of skinData) for (const entry of skinData)
skinDB skinDB.prepare(`
.prepare(`
INSERT INTO "skindata" INSERT INTO "skindata"
( (
timestamp, $timestamp,
player, $player,
clan, $clan,
flag, $flag,
skin, $skin,
useColor, $useColor,
colorBodyRaw, $colorBodyRaw,
colorBodyHex, $colorBodyHex,
colorFeetRaw, $colorFeetRaw,
ColorFeetHex $ColorFeetHex
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) )
`) `)
.run( .run({
currentTime, timestamp: currentTime,
entry.player, player: entry.player,
entry.clan, clan: entry.clan,
entry.flag, flag: entry.flag,
entry.skindata.skin, skin: entry.skindata.skin,
entry.skindata.useColor, useColor: entry.skindata.useColor,
entry.skindata.colorBody.raw, colorBodyRaw: entry.skindata.colorBody.raw,
entry.skindata.colorBody.hex, colorBodyHex: entry.skindata.colorBody.hex,
entry.skindata.colorFeet.raw, colorFeetRaw: entry.skindata.colorFeet.raw,
entry.skindata.colorFeet.hex, colorFeetHex: entry.skindata.colorFeet.hex,
) })
} catch (e) { } catch (e) {
log(`Failed to handle ${server}!`) log(`Failed to handle ${server}!`)
} }