This commit is contained in:
Professional 2025-05-24 02:24:21 +07:00
parent 19a041266d
commit e46b9f268e

View File

@ -486,7 +486,13 @@ const getUserStats = async (req, res, next) => {
readBy: { $ne: currentUserId } // Которые текущий пользователь не читал readBy: { $ne: currentUserId } // Которые текущий пользователь не читал
}); });
// 4. Получаем количество просмотров профиля // 4. Получаем общее количество сообщений пользователя
const totalMessagesCount = await Message.countDocuments({
conversationId: { $in: conversationIds },
sender: currentUserId // Только сообщения, отправленные текущим пользователем
});
// 5. Получаем количество просмотров профиля
const profileViewsCount = await ProfileView.countDocuments({ const profileViewsCount = await ProfileView.countDocuments({
profileOwner: currentUserId profileOwner: currentUserId
}); });
@ -495,7 +501,8 @@ const getUserStats = async (req, res, next) => {
profileViews: profileViewsCount, profileViews: profileViewsCount,
likes: likesCount, likes: likesCount,
matches: matchesCount, matches: matchesCount,
unreadMessages: unreadMessagesCount unreadMessages: unreadMessagesCount,
totalMessages: totalMessagesCount // Добавляем новое значение в ответ
}; };
console.log(`[USER_CTRL] Статистика пользователя ${currentUserId}:`, stats); console.log(`[USER_CTRL] Статистика пользователя ${currentUserId}:`, stats);