File tree Expand file tree Collapse file tree
backend/src/serverless/integrations/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -207,15 +207,20 @@ export class IntegrationTickProcessor extends LoggerBase {
207207 integration . id ,
208208 )
209209 if ( ! existingRun ) {
210- const rand = Math . random ( )
211- // 50% chance to delay the triggering of new integration checks for Discord integrations
212- if ( newIntService . type === IntegrationType . DISCORD && rand > 0.5 ) {
213- // Delay the triggering of new integration checks for Discord integrations
214- const delay = 30 * 60 * 1000 // 30 minutes in milliseconds
210+ const CHUNKS = 3 // Define the number of chunks
211+ const DELAY_BETWEEN_CHUNKS = 30 * 60 * 1000 // Define the delay between chunks in milliseconds
212+ const rand = Math . random ( ) * CHUNKS
213+ const chunkIndex = Math . min ( Math . floor ( rand ) , CHUNKS - 1 )
214+ const delay = chunkIndex * DELAY_BETWEEN_CHUNKS
215+
216+ // Divide integrations into chunks for Discord
217+ if ( newIntService . type === IntegrationType . DISCORD ) {
215218 setTimeout ( async ( ) => {
216219 logger . info (
217220 { integrationId : integration . id } ,
218- 'Triggering new delayed integration check for Discord!' ,
221+ `Triggering new delayed integration check for Discord in ${
222+ delay / 60 / 1000
223+ } minutes!`,
219224 )
220225 await emitter . triggerIntegrationRun (
221226 integration . tenantId ,
You can’t perform that action at this time.
0 commit comments