From 9f82f436f085cf507ae6871f1eda577251ae6100 Mon Sep 17 00:00:00 2001 From: Rohit Narurkar Date: Fri, 26 Apr 2019 10:15:15 +0800 Subject: [PATCH] make sure admins/officers are not deleted --- dbWrapper/mongoUtil.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dbWrapper/mongoUtil.js b/dbWrapper/mongoUtil.js index a790d2f..be93339 100644 --- a/dbWrapper/mongoUtil.js +++ b/dbWrapper/mongoUtil.js @@ -6,6 +6,10 @@ const { collections, } = require('../helpers/constants'); +const { + getAddressesDetails, +} = require('./addresses'); + const keystore = require('../keystore/kyc-admin.json'); let _db; @@ -38,6 +42,11 @@ const initToResyncDb = async () => { const initToProcessOnlyDb = async () => { console.log('in initToProcessOnlyDb'); + + // read who the current forum admin/kyc admins are + const kycAdmins = await getAddressesDetails({ isKycOfficer: true }); + const forumAdmins = await getAddressesDetails({ isForumAdmin: true }); + // wipe everything except synced transactions await _emptyCollections([ collections.ADDRESSES, @@ -61,6 +70,20 @@ const initToProcessOnlyDb = async () => { }, }); + const kycAdminsInsertions = kycAdmins.map((item) => { + return { + address: item.address, + isKycOfficer: true, + }; + }); + const forumAdminsInsertions = forumAdmins.map((item) => { + return { + address: item.address, + isForumAdmin: true, + }; + }); + await _db.collection(collections.ADDRESSES).insertMany(kycAdminsInsertions.concat(forumAdminsInsertions)); + console.log('cleared DB, except synced transactions. Will now start reprocessing'); };