ソースを参照

tmp: disable decorating with associations on revisions

Karol Sójko 1 年間 前
コミット
ac3646836c

+ 1 - 1
packages/syncing-server/src/Domain/Handler/ItemRevisionCreationRequestedEventHandler.ts

@@ -24,7 +24,7 @@ export class ItemRevisionCreationRequestedEventHandler implements DomainEventHan
     }
     const itemUuid = itemUuidOrError.getValue()
 
-    const item = await this.itemRepository.findByUuid(itemUuid)
+    const item = await this.itemRepository.findByUuid(itemUuid, true)
     if (item === null) {
       return
     }

+ 1 - 1
packages/syncing-server/src/Domain/Item/ItemRepositoryInterface.ts

@@ -17,7 +17,7 @@ export interface ItemRepositoryInterface {
   findDatesForComputingIntegrityHash(userUuid: string): Promise<Array<{ updated_at_timestamp: number }>>
   findItemsForComputingIntegrityPayloads(userUuid: string): Promise<ExtendedIntegrityPayload[]>
   findByUuidAndUserUuid(uuid: string, userUuid: string): Promise<Item | null>
-  findByUuid(uuid: Uuid): Promise<Item | null>
+  findByUuid(uuid: Uuid, noAssociations: boolean): Promise<Item | null>
   remove(item: Item): Promise<void>
   save(item: Item): Promise<void>
   markItemsAsDeleted(itemUuids: Array<string>, updatedAtTimestamp: number): Promise<void>

+ 1 - 1
packages/syncing-server/src/Domain/UseCase/Syncing/SaveItems/SaveItems.ts

@@ -42,7 +42,7 @@ export class SaveItems implements UseCaseInterface<SaveItemsResult> {
       }
       const itemUuid = itemUuidOrError.getValue()
 
-      const existingItem = await this.itemRepository.findByUuid(itemUuid)
+      const existingItem = await this.itemRepository.findByUuid(itemUuid, false)
 
       if (dto.readOnlyAccess) {
         conflicts.push({

+ 5 - 1
packages/syncing-server/src/Infra/TypeORM/TypeORMItemRepository.ts

@@ -77,7 +77,7 @@ export class TypeORMItemRepository implements ItemRepositoryInterface {
       .execute()
   }
 
-  async findByUuid(uuid: Uuid): Promise<Item | null> {
+  async findByUuid(uuid: Uuid, noAssociations: boolean): Promise<Item | null> {
     const persistence = await this.ormRepository
       .createQueryBuilder('item')
       .where('item.uuid = :uuid', {
@@ -92,6 +92,10 @@ export class TypeORMItemRepository implements ItemRepositoryInterface {
     try {
       const item = this.mapper.toDomain(persistence)
 
+      if (noAssociations) {
+        return item
+      }
+
       await this.decorateItemWithAssociations(item)
 
       return item