From 33547395909601ee5b90dd5dec7e5e30c4646080 Mon Sep 17 00:00:00 2001 From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com> Date: Wed, 20 Sep 2023 15:55:53 +0400 Subject: [PATCH] [FEATURE]: add javascript usage for scripts --- src/migrations/utils/webhookLogic.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/migrations/utils/webhookLogic.ts b/src/migrations/utils/webhookLogic.ts index 0182b1f2..0e8e1784 100644 --- a/src/migrations/utils/webhookLogic.ts +++ b/src/migrations/utils/webhookLogic.ts @@ -20,6 +20,10 @@ async function fetchMessagesBetweenOldestAndNewest( ) { try { let allMessages: Message[] = []; + logger.info( + { guild_id: connection.name, channel_id: channel.id }, + 'Fetching channel messages is running' + ); const options: FetchOptions = { limit: 100 }; options.after = oldestRawInfo.messageId; let fetchedMessages = await channel.messages.fetch(options); @@ -38,10 +42,16 @@ async function fetchMessagesBetweenOldestAndNewest( 'Fetching channel messages failed' ); } + logger.info( + { guild_id: connection.name, channel_id: channel.id }, + 'Fetching channel messages is done' + ); } async function migrateIsGeneratedByWebhook(connection: Connection, channel: TextChannel) { try { + logger.info({ guild_id: connection.name, channel_id: channel.id }, 'Migration for isGeneratedByWebhook is running'); + // Fetch oldest rawInfo from DB const oldestChannelRawInfo = await rawInfoService.getOldestRawInfo(connection, { channelId: channel?.id, @@ -149,6 +159,8 @@ async function migrateIsGeneratedByWebhook(connection: Connection, channel: Text } } + logger.info({ guild_id: connection.name, channel_id: channel.id }, 'Migration for isGeneratedByWebhook is done'); + } catch (err) { logger.error({ guild_id: connection.name, channel_id: channel.id, err }, 'Migration for isGeneratedByWebhook failed'); } @@ -162,6 +174,7 @@ async function migrateIsGeneratedByWebhook(connection: Connection, channel: Text * @param {Snowflake} guildId - The identifier of the guild to extract information from. */ async function runRawInfoMigration(connection: Connection, client: Client, guildId: Snowflake) { + logger.info({ guild_id: guildId }, 'Migration is running'); try { const guild = await client.guilds.fetch(guildId); const channels = await channelService.getChannels(connection, {}); @@ -175,6 +188,7 @@ async function runRawInfoMigration(connection: Connection, client: Client, guild } catch (err) { logger.error({ guild_id: guildId, err }, 'Migration is failed'); } + logger.info({ guild_id: guildId }, 'Migration is done'); } export default runRawInfoMigration; \ No newline at end of file