mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
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.
This commit is contained in:
parent
8635f4efeb
commit
fe4c0b18cf
2 changed files with 4 additions and 9 deletions
|
@ -105,7 +105,6 @@ type QueryOptions = {
|
||||||
|
|
||||||
interface PostsRepository {
|
interface PostsRepository {
|
||||||
getAll(options: QueryOptions): Promise<CollectionPost[]>;
|
getAll(options: QueryOptions): Promise<CollectionPost[]>;
|
||||||
getBulk(ids: string[], transaction?: Knex.Transaction): Promise<CollectionPost[]>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CollectionsService {
|
export class CollectionsService {
|
||||||
|
@ -392,8 +391,10 @@ export class CollectionsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async updatePostsInCollections(postIds: string[], collections: Collection[], transaction: Knex.Transaction) {
|
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 collection of collections) {
|
||||||
for (const post of posts) {
|
for (const post of posts) {
|
||||||
|
|
|
@ -10,10 +10,4 @@ export class PostsRepositoryInMemory extends InMemoryRepository<string, Collecti
|
||||||
tags: entity.tags.map(tag => tag.slug)
|
tags: entity.tags.map(tag => tag.slug)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBulk(ids: string[]) {
|
|
||||||
return this.getAll({
|
|
||||||
filter: `id:[${ids.join(',')}]`
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue