@@ -3,7 +3,7 @@ const DeactivatedUsers = require("../models/DeactivatedUsers.js");
33// const PersonalInfo = require("../models/PersonalInfo.js");
44const UserProfile = require ( "../models/UserProfile.js" ) ;
55const { GuestEmails } = require ( "../shared/constants.js" ) ;
6- const { calculateMatchingScore, cumulateMatchingFactors, shuffleProfiles, paginateCombined } = require ( "../utils/feedAlgorithm.js" ) ;
6+ const { calculateMatchingScore, cumulateMatchingFactors, shuffleProfiles, pickUsers } = require ( "../utils/feedAlgorithm.js" ) ;
77
88async function cleanUserProfiles ( userProfiles , email ) {
99 const blockedUsers = await BlockedUserList . findOne ( {
@@ -56,7 +56,7 @@ exports.getFeed = async(req, res) => {
5656 } ) ;
5757
5858 if ( ! currUser
59- || ! currUser . personalityType
59+ // || !currUser.personalityType
6060 ) {
6161 return res
6262 . json ( {
@@ -65,7 +65,7 @@ exports.getFeed = async(req, res) => {
6565 } ) ;
6666 }
6767
68- const currUserScoreFactors = cumulateMatchingFactors ( currUser ) ;
68+ // const currUserScoreFactors = cumulateMatchingFactors(currUser);
6969
7070 let userProfiles = await UserProfile . find ( {
7171 ...newFilters ,
@@ -83,11 +83,11 @@ exports.getFeed = async(req, res) => {
8383 const lessPreferredGenderUser = [ ] ;
8484
8585 userProfiles . forEach ( otherUser => {
86- const otherUserScoreFactors = cumulateMatchingFactors ( otherUser ) ;
87- const scoredProfile = {
88- score : calculateMatchingScore ( currUserScoreFactors , otherUserScoreFactors ) ,
89- ...( otherUser . toObject ( ) )
90- } ;
86+ // const otherUserScoreFactors = cumulateMatchingFactors(otherUser);
87+ // const scoredProfile = {
88+ // score : calculateMatchingScore(currUserScoreFactors , otherUserScoreFactors) ,
89+ // ...(otherUser.toObject())
90+ // };
9191
9292 if (
9393 (
@@ -98,25 +98,13 @@ exports.getFeed = async(req, res) => {
9898 && otherUser . gender . toLowerCase ( ) === currUser . gender . toLowerCase ( )
9999 )
100100 ) {
101- morePreferredGenderUser . push ( scoredProfile ) ;
101+ morePreferredGenderUser . push ( otherUser ) ;
102102 } else {
103- lessPreferredGenderUser . push ( scoredProfile ) ;
103+ morePreferredGenderUser . push ( otherUser ) ;
104104 }
105105 } ) ;
106-
107- shuffleProfiles ( morePreferredGenderUser ) ;
108- shuffleProfiles ( lessPreferredGenderUser ) ;
109-
110- const pageNumber = parseInt ( req . params . pageNumber , 10 ) || 0 ;
111- const pageSize = 10 ;
112- const startIndex = pageNumber * pageSize ;
113-
114- const paginatedUsers = paginateCombined (
115- morePreferredGenderUser ,
116- lessPreferredGenderUser ,
117- startIndex ,
118- pageSize
119- ) ;
106+
107+ let paginatedUsers = pickUsers ( morePreferredGenderUser , lessPreferredGenderUser ) ;
120108
121109 shuffleProfiles ( paginatedUsers ) ;
122110
0 commit comments