From 8c8932f5f68f3f76a84ce7dcd9b8ef95a56c2e76 Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Mon, 29 Jan 2024 08:30:50 +0100 Subject: [PATCH] fix(api): deploying sync now keeps frequency override (#1556) --- .../services/sync/config/deploy.service.ts | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/packages/shared/lib/services/sync/config/deploy.service.ts b/packages/shared/lib/services/sync/config/deploy.service.ts index a0528e75cd..6e76ad2c4a 100644 --- a/packages/shared/lib/services/sync/config/deploy.service.ts +++ b/packages/shared/lib/services/sync/config/deploy.service.ts @@ -298,15 +298,20 @@ export async function deployPreBuilt( if (previousSyncAndActionConfig) { bumpedVersion = increment(previousSyncAndActionConfig.version as string | number).toString(); - const syncs = await getSyncsByProviderConfigAndSyncName(environment_id, provider_config_key, sync_name); - for (const sync of syncs) { - if (!runs) { - continue; - } - const { success, error } = await updateSyncScheduleFrequency(sync.id as string, runs, sync_name, environment_id, activityLogId as number); - - if (!success) { - return { success, error, response: null }; + if (runs) { + const syncsConfig = await getSyncsByProviderConfigAndSyncName(environment_id, provider_config_key, sync_name); + for (const syncConfig of syncsConfig) { + const { success, error } = await updateSyncScheduleFrequency( + syncConfig.id as string, + syncConfig?.frequency || runs, + sync_name, + environment_id, + activityLogId as number + ); + + if (!success) { + return { success, error, response: null }; + } } } } @@ -563,15 +568,21 @@ async function compileDeployInfo( }); } - const syncs = await getSyncsByProviderConfigAndSyncName(environment_id, providerConfigKey, syncName); - for (const sync of syncs) { - if (!runs) { - continue; - } - const { success, error } = await updateSyncScheduleFrequency(sync.id as string, runs, syncName, environment_id, activityLogId as number); + if (runs) { + const syncsConfig = await getSyncsByProviderConfigAndSyncName(environment_id, providerConfigKey, syncName); - if (!success) { - return { success, error, response: null }; + for (const syncConfig of syncsConfig) { + const { success, error } = await updateSyncScheduleFrequency( + syncConfig.id as string, + syncConfig?.frequency || runs, + syncName, + environment_id, + activityLogId as number + ); + + if (!success) { + return { success, error, response: null }; + } } } }