From 2d6a3ebf45a247b6a6ef2b7a32f685d9e746b0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Tue, 28 Nov 2023 11:21:48 +0100 Subject: [PATCH] fix(syncing-server): add debug logs about sending items changed event --- .../src/Domain/UseCase/Syncing/SaveItems/SaveItems.spec.ts | 1 + .../src/Domain/UseCase/Syncing/SaveItems/SaveItems.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/packages/syncing-server/src/Domain/UseCase/Syncing/SaveItems/SaveItems.spec.ts b/packages/syncing-server/src/Domain/UseCase/Syncing/SaveItems/SaveItems.spec.ts index 973ca213c..5b3184388 100644 --- a/packages/syncing-server/src/Domain/UseCase/Syncing/SaveItems/SaveItems.spec.ts +++ b/packages/syncing-server/src/Domain/UseCase/Syncing/SaveItems/SaveItems.spec.ts @@ -81,6 +81,7 @@ describe('SaveItems', () => { updateExistingItem.execute = jest.fn().mockResolvedValue(Result.ok(savedItem)) logger = {} as jest.Mocked + logger.debug = jest.fn() logger.error = jest.fn() itemHash1 = ItemHash.create({ diff --git a/packages/syncing-server/src/Domain/UseCase/Syncing/SaveItems/SaveItems.ts b/packages/syncing-server/src/Domain/UseCase/Syncing/SaveItems/SaveItems.ts index 96b66e3bb..f23f30e82 100644 --- a/packages/syncing-server/src/Domain/UseCase/Syncing/SaveItems/SaveItems.ts +++ b/packages/syncing-server/src/Domain/UseCase/Syncing/SaveItems/SaveItems.ts @@ -160,8 +160,11 @@ export class SaveItems implements UseCaseInterface { const tenPercentSpreadArray = Array.from(Array(10).keys()) const diceRoll = this.deterministicSelector.select(dto.userUuid, tenPercentSpreadArray) if (diceRoll !== 1) { + this.logger.debug(`[${dto.userUuid}] Not sending items changed event to client.`) + return } + this.logger.debug(`[${dto.userUuid}] Sending items changed event to client.`) const itemsChangedEvent = this.domainEventFactory.createItemsChangedOnServerEvent({ userUuid: dto.userUuid,