function for updating all existing accounts

merge-requests/4/head
Matthew 2020-05-03 17:50:06 -04:00
parent 3985b0c3aa
commit 4f1a9b01d9
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,26 @@
import { Client } from '..';
export default async function existingLimitsSetup(client: Client): Promise<number> {
const tier1 = await client.db.Tier.findOne({ id: 1 });
const tier2 = await client.db.Tier.findOne({ id: 2 });
const tier3 = await await client.db.Tier.findOne({ id: 3 });
const accounts = await client.db.Account.find();
let numOfAccountsUpdated = 0;
for (const account of accounts) {
if (account.tier === 1) {
account.updateOne({ $set: { ramLimitNotification: tier1.resourceLimits.ram - 20 } });
numOfAccountsUpdated += 1;
}
if (account.tier === 2) {
account.updateOne({ $set: { ramLimitNotification: tier2.resourceLimits.ram - 20 } });
numOfAccountsUpdated += 1;
}
if (account.tier === 3) {
account.updateOne({ $set: { ramLimitNotification: tier3.resourceLimits.ram - 20 } });
numOfAccountsUpdated += 1;
}
}
return numOfAccountsUpdated;
}

View File

@ -1,4 +1,5 @@
export { default as checkLock, clear as clearLock } from '../intervals/checkLock';
export { default as dataConversion } from './dataConversion';
export { default as existingLimitsSetup } from './existingLimitsSetup';
// export { default as checkSS, clear as clearSS } from './checkSS';
export { default as parseCertificate, Certificate } from './parseCertificate';