Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
recap committed Apr 2, 2024
1 parent 5e8996a commit 81c2e7a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"devDependencies": {
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.1.0",
"prettier": "3.2.5"
}
}
4 changes: 2 additions & 2 deletions schedulers/gat-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class GatScheduler {
const playersToWaitFor = this.playersToWaitFor()
this.queue.getQueue().forEach((user) => {
if (!user) {
console.error(`User ${userId} not found!`)
console.error(`User ${user.userId} not found!`)
return
}
const sock = user.webSocket
if (!sock) {
console.error(`Socket for ${userId} not found!`)
console.error(`Socket for ${user.userId} not found!`)
return
}
sock.emit("queueUpdate", {
Expand Down
12 changes: 7 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function getOtreeUrls(otreeIPs, otreeRestKey) {
results.push({
server: s,
experimentName: experimentName,
experimentUrl: experimentUrl
experimentUrl: experimentUrl,
})
})
})
Expand Down Expand Up @@ -195,7 +195,9 @@ function startReadyGames(experiments, agreementIds, usersDb) {
const experiment = experiments[experimentId]
const scheduler = experiment.scheduler
if (!scheduler) {
console.error(`[ERROR] No scheduler set for experiment ${experimentId}. Check config.json.`)
console.error(
`[ERROR] No scheduler set for experiment ${experimentId}. Check config.json.`,
)
continue
}

Expand Down Expand Up @@ -316,16 +318,16 @@ async function main() {
process.exit(1)
}

// Maybe only check for every new user queued instead on interval.
// Maybe only check for every new user queued instead on interval.
// setInterval(async () => {
// await getExperimentUrls(experiments)
// startReadyGames(experiments, agreementIds, usersDb)
// }, 1000)

let lastUpdate = new Date()
async function getUrlsAndStartGames(experiments, agreementIds, usersDb){
async function getUrlsAndStartGames(experiments, agreementIds, usersDb) {
const now = new Date()
const tDiff = Math.abs( (now.getTime() - lastUpdate.getTime()) / 1000 )
const tDiff = Math.abs((now.getTime() - lastUpdate.getTime()) / 1000)
if (tDiff > 30) {
lastUpdate = now
console.log(`Updating URLs. Last update was ${tDiff} seconds ago.`)
Expand Down

0 comments on commit 81c2e7a

Please sign in to comment.