mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
statistics bug
This commit is contained in:
@@ -38,7 +38,7 @@ export class ClientStatisticsService {
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
.from(ClientStatisticsEntity)
|
||||
.where('time < :time', { time: oneDayAgo })
|
||||
.where('time < :time', { time: oneDayAgo.getTime() })
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ export class ClientService {
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
.from(ClientEntity)
|
||||
.where('deletedAt < :time', { time: oneDayAgo })
|
||||
.where('deletedAt < :deletedAt', { deletedAt: oneDayAgo })
|
||||
.execute();
|
||||
|
||||
}
|
||||
|
||||
@@ -19,9 +19,11 @@ export class CleanupService implements OnModuleInit {
|
||||
|
||||
@Cron(CronExpression.EVERY_HOUR)
|
||||
private async deleteOldStatistics() {
|
||||
if (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0') {
|
||||
const deletedStatistics = await this.clientStatisticsService.deleteOldStatistics();
|
||||
console.log(`Deleted ${deletedStatistics.affected} old statistics`);
|
||||
const deletedClients = await this.clientService.deleteOldClients();
|
||||
console.log(`Deleted ${deletedClients.affected} old clients`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ export class DiscordService implements OnModuleInit {
|
||||
|
||||
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
if (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0') {
|
||||
this.token = this.configService.get('DISCORD_BOT_TOKEN');
|
||||
this.clientId = this.configService.get('DISCORD_BOT_CLIENTID');
|
||||
this.guildId = this.configService.get('DISCORD_BOT_GUILD_ID');
|
||||
@@ -56,16 +57,17 @@ export class DiscordService implements OnModuleInit {
|
||||
this.bot = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });
|
||||
this.bot.login(this.token);
|
||||
}
|
||||
}
|
||||
|
||||
async onModuleInit(): Promise<void> {
|
||||
|
||||
if (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0') {
|
||||
if (this.bot == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.registerCommands();
|
||||
|
||||
|
||||
this.bot.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
@@ -88,8 +90,10 @@ export class DiscordService implements OnModuleInit {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async registerCommands() {
|
||||
if (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0') {
|
||||
const rest = new REST().setToken(this.token);
|
||||
try {
|
||||
console.log(`Started refreshing ${commands.length} application (/) commands.`);
|
||||
@@ -106,8 +110,10 @@ export class DiscordService implements OnModuleInit {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async notifyRestarted() {
|
||||
if (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0') {
|
||||
if (this.bot == null) {
|
||||
return;
|
||||
}
|
||||
@@ -116,14 +122,17 @@ export class DiscordService implements OnModuleInit {
|
||||
const channel = await guild.channels.fetch(this.channelId) as TextChannel;
|
||||
channel.send(`Server Restarted.`);
|
||||
}
|
||||
}
|
||||
|
||||
public async notifySubscribersBlockFound(height: number, block: Block, message: string) {
|
||||
if (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0') {
|
||||
if (this.bot == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const guild = await this.bot.guilds.fetch(this.guildId);
|
||||
const channel = await guild.channels.fetch(this.channelId) as TextChannel;
|
||||
channel.send(`Block Found! Result: ${message}, Height: ${height}`)
|
||||
channel.send(`Block Found! Result: ${message}, Height: ${height}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user