1
0
Fork 0
refactor/models
Bsian 2020-05-04 01:00:52 +01:00
parent c7fb133a23
commit 3030db18d9
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
3 changed files with 11 additions and 9 deletions

View File

@ -2,7 +2,7 @@
/* eslint-disable no-await-in-loop */
import { Client } from '..';
import { RichEmbed } from '../class';
import { TierInterface } from '../models';
import { Tiers } from '../models';
const channelID = '691824484230889546';
@ -18,7 +18,7 @@ export default function memory(client: Client) {
// memory in megabytes
const memoryConversion = mem / 1024 / 1024;
const userLimits: { soft?: number, hard?: number } = {};
const tier: TierInterface = await client.db.Tier.findOne({ id: acc.tier }).lean().exec();
const tier: Tiers = await client.db.Tier.findOne({ id: acc.tier }).lean().exec();
userLimits.soft = acc.ramLimitNotification;
userLimits.hard = tier.resourceLimits.ram;
if ((memoryConversion <= userLimits.soft) && (acc.ramLimitNotification !== 0)) {

View File

@ -1,13 +1,15 @@
import { Document, Schema, model } from 'mongoose';
export interface TierInterface extends Document {
export interface Tiers {
id: number,
resourceLimits: {
// in MB
ram: number,
// in MB
storage: number,
},
// In MB
ram: number, storage: number
}
}
export interface TierInterface extends Tiers, Document {
id: number;
}
const Tier: Schema = new Schema({

View File

@ -1,4 +1,4 @@
export { default as Account, AccountInterface } from './Account';
export { default as Moderation, ModerationInterface } from './Moderation';
export { default as Domain, DomainInterface } from './Domain';
export { default as Tier, TierInterface } from './Tier';
export { default as Tier, TierInterface, Tiers } from './Tier';