fix: shop profile product count — approved-only for visitors, total for owner
توی پروفایل عمومی فروشگاه تعداد کالا فقط شاملِ کالاهای تاییدشده (active) میشه؛ خودِ مالک فروشگاه توی پروفایلِ خودش تعداد کل کالاها (هر وضعیتی) رو میبینه. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -212,10 +212,11 @@ const getShopPublic = async (req, res, next) => {
|
||||
return shopError(res, 404, 'فروشگاه یافت نشد')
|
||||
}
|
||||
|
||||
const productCount = await ShopProductListingModel.countDocuments({
|
||||
shop: shop._id,
|
||||
status: { $in: ['active', 'pending_shop_approval'] }
|
||||
})
|
||||
// طبق خواستهی کاربر: بازدیدکنندهی عمومی فقط تعداد کالاهای تاییدشده (active) رو
|
||||
// ببینه؛ خودِ مالکِ فروشگاه توی پروفایلِ خودش تعداد کلِ کالاها (هر وضعیتی) رو ببینه
|
||||
const productCount = isOwner
|
||||
? await ShopProductListingModel.countDocuments({ shop: shop._id })
|
||||
: await ShopProductListingModel.countDocuments({ shop: shop._id, status: 'active' })
|
||||
|
||||
const ratingAgg = await ShopRatingModel.aggregate([
|
||||
{ $match: { shop: shop._id } },
|
||||
|
||||
Reference in New Issue
Block a user