From e46b9f268e17e2cb7c7b9f36d19e16fe062866c6 Mon Sep 17 00:00:00 2001 From: Professional Date: Sat, 24 May 2025 02:24:21 +0700 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/controllers/userController.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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);