forked from engineering/cloudservices
function for updating all existing accounts
parent
3985b0c3aa
commit
4f1a9b01d9
|
@ -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;
|
||||
}
|
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue