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*
players.msgpack
.env
ddnss/build
ddnss/

View File

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