1
1
mirror of https://github.com/Burn-E99/TheArtificer.git synced 2026-06-04 09:03:50 -04:00

Create roll heatmap table and sproc, add dailyRate to command_cnt table

This commit is contained in:
Ean Milligan (Bastion)
2022-06-25 02:09:41 -04:00
parent 011120845e
commit b69cf2060f
4 changed files with 56 additions and 2 deletions

View File

@@ -16,7 +16,9 @@ import utils from '../utils.ts';
export const roll = async (message: DiscordenoMessage, args: string[], command: string) => {
// Light telemetry to see how many times a command is being run
dbClient.execute(queries.callIncCnt('roll')).catch((e) => utils.commonLoggers.dbError('roll.ts:19', 'call sproc INC_CNT on', e));
const currDateTime = new Date();
dbClient.execute(queries.callIncCnt('roll')).catch((e) => utils.commonLoggers.dbError('roll.ts:20', 'call sproc INC_CNT on', e));
dbClient.execute(queries.callIncHeatmap(currDateTime)).catch((e) => utils.commonLoggers.dbError('roll.ts:21', 'update', e));
// If DEVMODE is on, only allow this command to be used in the devServer
if (DEVMODE && message.guildId !== config.devServer) {

View File

@@ -10,7 +10,10 @@ export const dbClient = await new Client().connect({
password: config.db.password,
});
const weekDays = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
export const queries = {
insertRollLogCmd: (api: number, error: number) => `INSERT INTO roll_log(input,result,resultid,api,error) values(?,?,?,${api},${error})`,
callIncCnt: (cmdName: string) => `CALL INC_CNT("${cmdName}");`,
callIncHeatmap: (dateObj: Date) => `CALL INC_HEATMAP("${weekDays[dateObj.getDay()]}", ${dateObj.getHours()});`,
};