update scoring system to be more efficient
parent
9e7e938c14
commit
ff0a254eae
|
@ -3,10 +3,11 @@
|
||||||
import Bull from 'bull';
|
import Bull from 'bull';
|
||||||
import { InqType, Score } from 'cr-db/mongodb';
|
import { InqType, Score } from 'cr-db/mongodb';
|
||||||
import cron from 'cron';
|
import cron from 'cron';
|
||||||
import { TextableChannel, TextChannel } from 'eris';
|
import { Message, TextableChannel, TextChannel } from 'eris';
|
||||||
import { Client, RichEmbed } from '.';
|
import { Client, RichEmbed } from '.';
|
||||||
|
|
||||||
import { apply as Apply } from '../commands';
|
import { apply as Apply } from '../commands';
|
||||||
|
import calculateReport from '../functions/calculateReport';
|
||||||
|
|
||||||
export default class Queue {
|
export default class Queue {
|
||||||
public client: Client;
|
public client: Client;
|
||||||
|
@ -55,8 +56,34 @@ export default class Queue {
|
||||||
this.client.db.mongo.ScoreHistorical.remove({ date: { $lt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) } });
|
this.client.db.mongo.ScoreHistorical.remove({ date: { $lt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) } });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const calculateScores = new cron.CronJob('0 * * * *', async () => {
|
||||||
|
const { members } = this.client.guilds.get(this.client.config.guildID);
|
||||||
|
|
||||||
|
const general = await (<TextChannel> this.client.guilds.get(this.client.config.guildID).channels.get('485680288123584525')).getMessages(2200);
|
||||||
|
const programmingSupport = await (<TextChannel> this.client.guilds.get(this.client.config.guildID).channels.get('506970598631538708')).getMessages(300);
|
||||||
|
const programmingSupport2 = await (<TextChannel> this.client.guilds.get(this.client.config.guildID).channels.get('554892820553531422')).getMessages(100);
|
||||||
|
const cloudSupport = await (<TextChannel> this.client.guilds.get(this.client.config.guildID).channels.get('546457788184789013')).getMessages(200);
|
||||||
|
|
||||||
|
const projectChannels: TextChannel[] = [];
|
||||||
|
for (const c of this.client.guilds.get(this.client.config.guildID).channels.filter((ch) => ch.type === 0)) {
|
||||||
|
const chan = <TextChannel> c;
|
||||||
|
if (chan.parentID !== '701591772186411108') continue;
|
||||||
|
projectChannels.push(chan);
|
||||||
|
}
|
||||||
|
const projectMessages: Message<TextChannel>[] = [];
|
||||||
|
for (const chan of projectChannels) {
|
||||||
|
const msg = await chan.getMessages(200);
|
||||||
|
projectMessages.push(...msg);
|
||||||
|
}
|
||||||
|
members.forEach(async member => {
|
||||||
|
const resolvedMember = await this.client.getRESTGuildMember(this.client.config.guildID, member.id);
|
||||||
|
calculateReport(this.client, resolvedMember, [...general, ...programmingSupport, ...programmingSupport2, ...cloudSupport, ...projectMessages])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
historialCommunityReportJob.start();
|
historialCommunityReportJob.start();
|
||||||
clearOldHistoricalReportsJob.start();
|
clearOldHistoricalReportsJob.start();
|
||||||
|
calculateScores.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async jobCounts() {
|
public async jobCounts() {
|
||||||
|
|
Loading…
Reference in New Issue