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