Factor in new subscoring model

pull/29/head
Matthew 2020-09-13 23:54:37 -04:00
parent 244cac9204
commit 55e9f9b390
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
2 changed files with 25 additions and 10 deletions

View File

@ -56,6 +56,7 @@ export default class Score extends Command {
let moderationScore = '0'; let moderationScore = '0';
let roleScore = '0'; let roleScore = '0';
let cloudServicesScore = '0'; let cloudServicesScore = '0';
let otherScore = '0';
let miscScore = '0'; let miscScore = '0';
if (score) { if (score) {
@ -73,13 +74,16 @@ export default class Score extends Command {
moderationScore = `${score.moderation}`; moderationScore = `${score.moderation}`;
if (score.other === 0) otherScore = '---';
else otherScore = `${score.other}`;
if (score.staff <= 0) miscScore = '---'; if (score.staff <= 0) miscScore = '---';
else miscScore = `${score.staff}`; else miscScore = `${score.staff}`;
if (score.cloudServices === 0) cloudServicesScore = '---'; if (score.cloudServices === 0) cloudServicesScore = '---';
else if (score.cloudServices > 50) cloudServicesScore = '50'; else if (score.cloudServices > 10) cloudServicesScore = '10';
else cloudServicesScore = `${score.cloudServices}`; else cloudServicesScore = `${score.cloudServices}`;
} else return this.error(message.channel, 'Community Score has not been calculated yet.'); } // else return this.error(message.channel, 'Community Score has not been calculated yet.');
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle('Community Score'); embed.setTitle('Community Score');
@ -105,11 +109,12 @@ export default class Score extends Command {
if (score.total >= 500) { color = '🟡'; embed.setColor('FFFF00'); } if (score.total >= 500) { color = '🟡'; embed.setColor('FFFF00'); }
if (score.total >= 700) { color = '🟢'; embed.setColor('66FF66'); } if (score.total >= 700) { color = '🟢'; embed.setColor('66FF66'); }
embed.addField('Total | 200 to 800', `${color} ${totalScore}`, true); embed.addField('Total | 200 to 800', `${color} ${totalScore}`, true);
embed.addField(`Activity | 10 to ${Math.floor(Math.log1p(5000 + 300 + 200 + 100) * 12)}`, activityScore, true); embed.addField(`Activity | 10 to ${Math.floor(Math.log1p(5000 + 300 + 200 + 100) * 12)}`, activityScore || 'N/C', true);
embed.addField('Roles | 1 to N/A', roleScore, true); embed.addField('Roles | 1 to N/A', roleScore || 'N/C', true);
embed.addField('Moderation | N/A to 2', moderationScore, true); embed.addField('Moderation | N/A to 2' || 'N/C', moderationScore, true);
embed.addField('Cloud Services | N/A to 10', cloudServicesScore, true); embed.addField('Cloud Services | N/A to 10', cloudServicesScore || 'N/C', true);
embed.addField('Misc', miscScore, true); embed.addField('Other', otherScore || 'N/C', true);
embed.addField('Misc', miscScore || 'N/C', true);
if (score.lastUpdate) { if (score.lastUpdate) {
embed.setFooter('Report last updated', this.client.user.avatarURL); embed.setFooter('Report last updated', this.client.user.avatarURL);
embed.setTimestamp(score.lastUpdate); embed.setTimestamp(score.lastUpdate);

View File

@ -36,6 +36,7 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
roles: number, roles: number,
moderation: number, moderation: number,
cloudServices: number, cloudServices: number,
other: number,
staff: boolean, staff: boolean,
inquiries: [{ name: string, reason: string}?], inquiries: [{ name: string, reason: string}?],
} = { } = {
@ -45,6 +46,7 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
roles: 0, roles: 0,
moderation: 0, moderation: 0,
cloudServices: 0, cloudServices: 0,
other: 0,
staff: false, staff: false,
inquiries: [], inquiries: [],
}; };
@ -55,7 +57,7 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
// eslint-disable-next-line prefer-const // eslint-disable-next-line prefer-const
// eslint-disable-next-line one-var-declaration-per-line // eslint-disable-next-line one-var-declaration-per-line
// eslint-disable-next-line one-var // eslint-disable-next-line one-var
let total = 0, activity = 0, roles = 0, moderation = 0, cloudServices = 0, staff = 0; let total = 0, activity = 0, roles = 0, moderation = 0, cloudServices = 0, other = 0, staff = 0;
cloudServices = 0; cloudServices = 0;
roles = Math.floor(member.roles.length * 0.50); roles = Math.floor(member.roles.length * 0.50);
@ -104,9 +106,17 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
else cloudServices = Math.floor(positives * 0.61); else cloudServices = Math.floor(positives * 0.61);
} }
total = Math.floor(((total + activity + roles + moderation + cloudServices + staff) * 5.13) * 1.87); if (score.inquiries?.length > 0) {
for (const inq of score.inquiries) {
const testDate = (new Date(new Date(inq.date).setHours(2190)));
if (testDate > new Date()) other -= 1.5;
}
other = Math.floor(other * 1.15);
}
await score.updateOne({ $set: { total, activity, roles, moderation, cloudServices, staff, lastUpdate: new Date() } }); total = Math.floor(((total + activity + roles + moderation + cloudServices + staff + other) * 5.13) * 1.87);
await score.updateOne({ $set: { total, activity, roles, moderation, cloudServices, other, staff, lastUpdate: new Date() } });
// client.util.signale.debug(`SCORE SET - ${member.username}\nTotal: ${total}\nActivity: ${activity}\nRoles: ${roles}\nModeration: ${moderation}\nCloud Services: ${cloudServices}\nStaff: ${staff}`); // client.util.signale.debug(`SCORE SET - ${member.username}\nTotal: ${total}\nActivity: ${activity}\nRoles: ${roles}\nModeration: ${moderation}\nCloud Services: ${cloudServices}\nStaff: ${staff}`);
} }
}; };