From 2360d2966b2b8334808762e7d7ab05376db1049a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 15 Jun 2023 20:36:35 -0400 Subject: [PATCH] refactor: remove script --- gg.js | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 gg.js diff --git a/gg.js b/gg.js deleted file mode 100644 index c49efdb2af..0000000000 --- a/gg.js +++ /dev/null @@ -1,48 +0,0 @@ -/* eslint-disable no-await-in-loop */ -/* globals require, console, process */ - -'use strict'; - -const nconf = require('nconf'); - -nconf.file({ - file: 'config.json', -}); - -nconf.defaults({ - base_dir: __dirname, - views_dir: './build/public/templates', - upload_path: 'public/uploads', -}); - -const db = require('./src/database'); - -db.init(async (err) => { - if (err) { - console.log(`NodeBB could not connect to your database. Error: ${err.message}`); - process.exit(); - } - - await search(); - console.log('done'); - process.exit(); -}); - -async function search() { - const batch = require('./src/batch'); - const topics = require('./src/topics'); - await batch.processSortedSet('topics:tid', async (tids) => { - await Promise.all(tids.map(async (tid) => { - const topicData = await db.getObjectFields(`topic:${tid}`, ['cid', 'tid', 'uid', 'oldCid', 'timestamp']); - if (topicData.cid && topicData.oldCid) { - const isMember = await db.isSortedSetMember(`cid:${topicData.oldCid}:uid:${topicData.uid}:tids`, topicData.tid); - if (isMember) { - await db.sortedSetRemove(`cid:${topicData.oldCid}:uid:${topicData.uid}:tids`, tid); - await db.sortedSetAdd(`cid:${topicData.cid}:uid:${topicData.uid}:tids`, topicData.timestamp, tid); - } - } - })); - }, { - batch: 500, - }); -} \ No newline at end of file