parent
c64137e136
commit
3c50485669
@ -0,0 +1,5 @@ |
||||
module.exports = (app, router) => { |
||||
router.get('/stats', (req, res) => res.json({ |
||||
users: Object.keys(app.cache.users).length |
||||
})); |
||||
}; |
@ -0,0 +1,21 @@ |
||||
const gs = require('gradient-string'); |
||||
const spinnies = require('dreidels'); |
||||
const chalk = require('chalk'); |
||||
|
||||
module.exports = async app => { |
||||
app.cache = { |
||||
users: {} |
||||
}; |
||||
|
||||
return new Promise(async resolve => { |
||||
const loaders = []; |
||||
const spin = new spinnies(); |
||||
|
||||
let userCache = spin.add("ar", {text: "Caching Users..."}); |
||||
loaders.push(require('./cache/users')(app, userCache)); |
||||
|
||||
await Promise.all(loaders); |
||||
console.log(''); |
||||
resolve(0); |
||||
}); |
||||
}; //robbery is cool :)
|
@ -0,0 +1,24 @@ |
||||
const chalk = require('chalk'); |
||||
|
||||
module.exports = async (app, spinner) => { |
||||
const Users = app.db.models.ani.users; |
||||
|
||||
return new Promise(async resolve => { |
||||
const st = new Date().getTime(); |
||||
|
||||
let amount = 1; |
||||
|
||||
for await (const user of Users.find()) { |
||||
app.cache.users[user.id] = {id: user.id, discord: user.discord}; |
||||
spinner.update({text: `${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${amount}`)} ${chalk.blueBright(`ani DB users.`)}`}); |
||||
amount++; |
||||
} |
||||
|
||||
const cacheTime = new Date().getTime() - st; |
||||
spinner.update({text: `${spinner.options.text.slice(0, 19).trim()} ${chalk.gray(`${cacheTime}ms >>`.padStart(8, '0').padStart(7, '0'))} ${spinner.options.text.slice(19).trim()}`}); |
||||
spinner.status('non-spinnable'); |
||||
|
||||
resolve(0); |
||||
}); |
||||
} //robbery is like, the best
|
||||
// ...it's my own code don't @ me
|
Loading…
Reference in new issue