From fe4c0b18cfa13130a24580c90c6d70bb91e8f4dc Mon Sep 17 00:00:00 2001 From: Naz Date: Mon, 31 Jul 2023 20:30:05 +0800 Subject: [PATCH] Removed unnecessary `getBulk` in PostsRepository refs https://github.com/TryGhost/Arch/issues/16 - The method ended up being used only once, so it makes no sense to complicate the interface without any gain. --- ghost/collections/src/CollectionsService.ts | 7 ++++--- ghost/collections/test/fixtures/PostsRepositoryInMemory.ts | 6 ------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/ghost/collections/src/CollectionsService.ts b/ghost/collections/src/CollectionsService.ts index f1267d0d91..7253573acb 100644 --- a/ghost/collections/src/CollectionsService.ts +++ b/ghost/collections/src/CollectionsService.ts @@ -105,7 +105,6 @@ type QueryOptions = { interface PostsRepository { getAll(options: QueryOptions): Promise; - getBulk(ids: string[], transaction?: Knex.Transaction): Promise; } export class CollectionsService { @@ -392,8 +391,10 @@ export class CollectionsService { } async updatePostsInCollections(postIds: string[], collections: Collection[], transaction: Knex.Transaction) { - const posts = await this.postsRepository.getBulk(postIds, transaction); - + const posts = await this.postsRepository.getAll({ + filter: `id:[${postIds.join(',')}]`, + transaction: transaction + }); for (const collection of collections) { for (const post of posts) { diff --git a/ghost/collections/test/fixtures/PostsRepositoryInMemory.ts b/ghost/collections/test/fixtures/PostsRepositoryInMemory.ts index bd8b28f9eb..944ff415e4 100644 --- a/ghost/collections/test/fixtures/PostsRepositoryInMemory.ts +++ b/ghost/collections/test/fixtures/PostsRepositoryInMemory.ts @@ -10,10 +10,4 @@ export class PostsRepositoryInMemory extends InMemoryRepository tag.slug) }; } - - async getBulk(ids: string[]) { - return this.getAll({ - filter: `id:[${ids.join(',')}]` - }); - } }