Skip to content

Commit

Permalink
fix random query bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bahram1249 committed Jul 22, 2024
1 parent 162f5d9 commit 48e3af1
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,13 @@ export class ProductQueryBuilderService {
const offsetRandom = await this.sequelize.query(
`SELECT RAND(CHECKSUM(NEWID()))* count(*) as offset FROM ECProducts
WHERE inventoryStatusId = ${InventoryStatusEnum.available}
AND isnull(ECProducts.isDeleted, 0) = 0
AND ECProducts.publishStatusId = ${PublishStatusEnum.publish}` +
AND isnull(ECProducts.isDeleted, 0) = 0
AND ECProducts.publishStatusId = ${PublishStatusEnum.publish}` +
filter.entityTypeId
? `AND ECProducts.entityTypeId = ${filter.entityTypeId}`
: '1=1 ' + (filter.brands.length > 0)
? `AND ECProducts.brandId IN (${filter.brands.toString()})`
: '1=1 ',
? ` AND ECProducts.entityTypeId = ${filter.entityTypeId}`
: ' 1=1' + (filter.brands.length > 0)
? ` AND ECProducts.brandId IN (${filter.brands.toString()})`
: ' 1=1',
{ type: QueryTypes.SELECT, raw: true },
);

Expand Down

0 comments on commit 48e3af1

Please sign in to comment.