This commit is contained in:
payacom
2026-08-31 20:45:41 +03:30
parent fa9f23c61d
commit 3f416a7a60
367 changed files with 621895 additions and 6443 deletions

View File

@@ -0,0 +1,82 @@
const PostModel = require('../../../models/PostModel')
const CommentModel = require('../../../models/CommentModel')
const AdvertisingCommentModel = require('../../../models/AdvertisingCommentModel')
const CourseCommentModel = require('../../../models/CourseComentModel')
const AdvertisingModel = require('../../../models/AdvertisingModel')
const ProjectModel = require('../../../models/ProjectModel')
const CourseModel = require('../../../models/CourseModel')
const AcademyContentModel = require('../../../models/AcademyContentModel')
const ShopModel = require('../../../models/ShopModel')
const ShopProductListingModel = require('../../../models/ShopProductListingModel')
const {
REVIEW_POST_STATUSES,
REVIEW_COMMENT_STATUSES,
REVIEW_PROJECT_STATUSES,
REVIEW_BILLBOARD_STATUSES,
TEMP_ACCEPT,
} = require('../../../utils/moderationStatus')
const getModerationStats = async (req, res, next) => {
try {
const token = req.header('Authorization')?.split(' ')[1]
if (!token) return res.status(401).send('Access Denied')
const [
posts,
comments,
vitrineComments,
academyComments,
billboards,
projects,
courses,
academyVideos,
pendingShops,
pendingShopProducts,
] = await Promise.all([
PostModel.countDocuments({ status: { $in: REVIEW_POST_STATUSES } }),
CommentModel.countDocuments({ status: { $in: REVIEW_COMMENT_STATUSES } }),
AdvertisingCommentModel.countDocuments({
status: { $in: REVIEW_COMMENT_STATUSES },
}),
CourseCommentModel.countDocuments({
status: { $in: REVIEW_COMMENT_STATUSES },
}),
AdvertisingModel.countDocuments({
status: { $in: REVIEW_BILLBOARD_STATUSES },
}),
ProjectModel.countDocuments({ status: { $in: REVIEW_PROJECT_STATUSES } }),
CourseModel.countDocuments({ status: TEMP_ACCEPT }),
AcademyContentModel.countDocuments({ status: TEMP_ACCEPT }),
ShopModel.countDocuments({ status: 'pending_review' }),
ShopProductListingModel.countDocuments({ status: 'pending_shop_approval' }),
])
res.status(200).json({
posts,
comments,
vitrineComments,
academyComments,
billboards,
projects,
courses,
academyVideos,
pendingShops,
pendingShopProducts,
total:
posts +
comments +
vitrineComments +
academyComments +
billboards +
projects +
courses +
academyVideos +
pendingShops +
pendingShopProducts,
})
} catch (error) {
next(error)
}
}
module.exports = { getModerationStats }