From e2c5e3277da624594072e4aa3b0f91822f4579b9 Mon Sep 17 00:00:00 2001
From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com>
Date: Thu, 26 Oct 2023 16:11:16 +0330
Subject: [PATCH] [FEATURE]: increase the JOB time limit + save 100 msgs

---
 src/functions/fetchMessages.ts | 22 +++++++++++-----------
 src/index.ts                   |  2 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/functions/fetchMessages.ts b/src/functions/fetchMessages.ts
index ddb3af5c..89185e59 100644
--- a/src/functions/fetchMessages.ts
+++ b/src/functions/fetchMessages.ts
@@ -152,27 +152,27 @@ async function fetchMessages(
         }
         channel instanceof ThreadChannel
           ? await pushMessagesToArray(connection, messagesToStore, [...fetchedMessages.values()], {
-              threadId: channel.id,
-              threadName: channel.name,
-              channelId: channel.parent?.id,
-              channelName: channel.parent?.name,
-            })
+            threadId: channel.id,
+            threadName: channel.name,
+            channelId: channel.parent?.id,
+            channelName: channel.parent?.name,
+          })
           : await pushMessagesToArray(connection, messagesToStore, [...fetchedMessages.values()]);
         break;
       }
 
       channel instanceof ThreadChannel
         ? await pushMessagesToArray(connection, messagesToStore, [...fetchedMessages.values()], {
-            threadId: channel.id,
-            threadName: channel.name,
-            channelId: channel.parent?.id,
-            channelName: channel.parent?.name,
-          })
+          threadId: channel.id,
+          threadName: channel.name,
+          channelId: channel.parent?.id,
+          channelName: channel.parent?.name,
+        })
         : await pushMessagesToArray(connection, messagesToStore, [...fetchedMessages.values()]);
+      await rawInfoService.createRawInfos(connection, messagesToStore);
       options[fetchDirection] = boundaryMessage.id;
       fetchedMessages = await channel.messages.fetch(options);
     }
-    await rawInfoService.createRawInfos(connection, messagesToStore);
   } catch (err) {
     logger.error(
       { guild_id: connection.name, channel_id: channel.id, fetchDirection, err },
diff --git a/src/index.ts b/src/index.ts
index 9452d186..902b627d 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -201,7 +201,7 @@ async function app() {
         port: config.redis.port,
         password: config.redis.password,
       },
-      lockDuration: 7200000, // 2 hour
+      lockDuration: 79200000, // 22 hours
     }
   );