Skip to content

Commit

Permalink
perf(core): Improve performance of apply-collection-filters job (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkostenko-jsninja authored Jun 2, 2021
1 parent 0ad4e6a commit 1e8c137
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/service/services/collection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ export class CollectionService implements OnModuleInit {
Logger.verbose(`Processing ${job.data.collectionIds.length} Collections`);
let completed = 0;
for (const collectionId of job.data.collectionIds) {
const collection = await this.connection.getRepository(Collection).findOne(collectionId, {
relations: ['productVariants'],
});
const collection = await this.connection.getRepository(Collection).findOne(collectionId);
if (!collection) {
Logger.warn(`Could not find Collection with id ${collectionId}, skipping`);
continue;
Expand Down Expand Up @@ -482,8 +480,10 @@ export class CollectionService implements OnModuleInit {
const productVariants = await this.connection
.getRepository(ctx, ProductVariant)
.createQueryBuilder('variant')
.select('variant.id', 'id')
.innerJoin('variant.collections', 'collection', 'collection.id = :id', { id: collection.id })
.getMany();
.getRawMany();

return productVariants.map(v => v.id);
}
}
Expand Down

0 comments on commit 1e8c137

Please sign in to comment.