From 0975959eb9e2ead4efc27ba7552799e19de224da Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 29 Oct 2018 19:32:20 +0900 Subject: [PATCH] Clean up --- cli/del-usr.js | 13 ------------- cli/mark-verified.js | 23 ----------------------- cli/recount-stats.js | 42 ------------------------------------------ 3 files changed, 78 deletions(-) delete mode 100644 cli/del-usr.js delete mode 100644 cli/mark-verified.js delete mode 100644 cli/recount-stats.js diff --git a/cli/del-usr.js b/cli/del-usr.js deleted file mode 100644 index 08e97845e..000000000 --- a/cli/del-usr.js +++ /dev/null @@ -1,13 +0,0 @@ -const deleteUser = require('../built/models/user').deleteUser; - -const args = process.argv.slice(2); - -const userId = args[0]; - -console.log(`deleting ${userId}...`); - -deleteUser(userId).then(() => { - console.log('done'); -}, e => { - console.error(e); -}); diff --git a/cli/mark-verified.js b/cli/mark-verified.js deleted file mode 100644 index cdee91ddc..000000000 --- a/cli/mark-verified.js +++ /dev/null @@ -1,23 +0,0 @@ -const mongo = require('mongodb'); -const User = require('../built/models/user').default; - -const args = process.argv.slice(2); - -const user = args[0]; - -const q = user.startsWith('@') ? { - username: user.split('@')[1], - host: user.split('@')[2] || null -} : { _id: new mongo.ObjectID(user) }; - -console.log(`Mark as verfied ${user}...`); - -User.update(q, { - $set: { - isVerified: true - } -}).then(() => { - console.log(`Done ${user}`); -}, e => { - console.error(e); -}); diff --git a/cli/recount-stats.js b/cli/recount-stats.js deleted file mode 100644 index 84cb5d0f5..000000000 --- a/cli/recount-stats.js +++ /dev/null @@ -1,42 +0,0 @@ -const { default: Note } = require('../built/models/note'); -const { default: Meta } = require('../built/models/meta'); -const { default: User } = require('../built/models/user'); - -async function main() { - const meta = await Meta.findOne({}); - - const notesCount = await Note.count(); - - const usersCount = await User.count(); - - const originalNotesCount = await Note.count({ - '_user.host': null - }); - - const originalUsersCount = await User.count({ - host: null - }); - - const stats = { - notesCount, - usersCount, - originalNotesCount, - originalUsersCount - }; - - if (meta) { - await Meta.update({}, { - $set: { - stats - } - }); - } else { - await Meta.insert({ - stats - }); - } -} - -main().then(() => { - console.log('done'); -}).catch(console.error);