Skip to content

Commit

Permalink
fix(graph): More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco (Valandur) committed Jan 8, 2020
1 parent 7437d74 commit 51325b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/framework/services/DatabaseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ export class DatabaseService {
'GROUP BY YEAR(`createdAt`), MONTH(`createdAt`), DAY(`createdAt`)',
[guildId, from, to]
);
return rows as Array<{ year: string; month: string; day: string; total: string }>;
return rows as Array<{ year: number; month: number; day: number; total: number }>;
}
public async getFirstJoinForMember(guildId: string, memberId: string) {
const [db, pool] = this.getDbInfo(guildId);
Expand Down Expand Up @@ -713,7 +713,7 @@ export class DatabaseService {
'GROUP BY YEAR(`createdAt`), MONTH(`createdAt`), DAY(`createdAt`)',
[guildId, from, to]
);
return rows as Array<{ year: string; month: string; day: string; total: string }>;
return rows as Array<{ year: number; month: number; day: number; total: number }>;
}
public async subtractLeaves(guildId: string, autoSubtractLeaveThreshold: number) {
const [db, pool] = this.getDbInfo(guildId);
Expand Down
8 changes: 4 additions & 4 deletions src/invites/commands/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ export default class extends Command {
const joinsMap = addDataset();
const fs = await this.client.db.getJoinsPerDay(guild.id, from.toDate(), to.toDate());
fs.forEach(join =>
joinsMap.set(`${join.year}-${join.month.padStart(2, '0')}-${join.day.padStart(2, '0')}`, Number(join.total))
joinsMap.set(`${join.year}-${`${join.month}`.padStart(2, '0')}-${`${join.day}`.padStart(2, '0')}`, join.total)
);

const leavesMap = addDataset();
const lvs = await this.client.db.getLeavesPerDay(guild.id, from.toDate(), to.toDate());
lvs.forEach(leave =>
leavesMap.set(
`${leave.year}-${leave.month.padStart(2, '0')}-${leave.day.padStart(2, '0')}`,
`${leave.year}-${`${leave.month}`.padStart(2, '0')}-${`${leave.day}`.padStart(2, '0')}`,
Number(leave.total)
)
);
Expand All @@ -103,7 +103,7 @@ export default class extends Command {
const map = addDataset();
const joins = await this.client.db.getJoinsPerDay(guild.id, from.toDate(), to.toDate());
joins.forEach(join =>
map.set(`${join.year}-${join.month.padStart(2, '0')}-${join.day.padStart(2, '0')}`, Number(join.total))
map.set(`${join.year}-${`${join.month}`.padStart(2, '0')}-${`${join.day}`.padStart(2, '0')}`, join.total)
);
} else if (type === ChartType.leaves) {
title = t('cmd.graph.leaves.title');
Expand All @@ -112,7 +112,7 @@ export default class extends Command {
const map = addDataset();
const leaves = await this.client.db.getLeavesPerDay(guild.id, from.toDate(), to.toDate());
leaves.forEach(leave =>
map.set(`${leave.year}-${leave.month.padStart(2, '0')}-${leave.day.padStart(2, '0')}`, Number(leave.total))
map.set(`${leave.year}-${`${leave.month}`.padStart(2, '0')}-${`${leave.day}`.padStart(2, '0')}`, leave.total)
);
}

Expand Down

0 comments on commit 51325b0

Please sign in to comment.