@@ -71,7 +71,7 @@ function matchUsers(channel, msg, userId, difficulty, category) {
71
71
const matchedUsers = waitingUsers [ criteriaKey ] . splice ( 0 , 2 ) ;
72
72
removeMatchedUsersFromOtherLists ( matchedUsers , criteriaKey ) ;
73
73
console . log ( "waitingusers after strict matching: " , waitingUsers )
74
- notifyMatch ( channel , matchedUsers , category ) ;
74
+ notifyMatch ( channel , matchedUsers , category , difficulty ) ;
75
75
return true ;
76
76
}
77
77
@@ -83,7 +83,7 @@ function matchUsers(channel, msg, userId, difficulty, category) {
83
83
const matchedUsers = waitingUsers [ categoryKey ] . splice ( 0 , 2 ) ;
84
84
removeMatchedUsersFromOtherLists ( matchedUsers , categoryKey ) ;
85
85
console . log ( "waitingusers after lenient matching: " , waitingUsers )
86
- notifyMatch ( channel , matchedUsers , category ) ;
86
+ notifyMatch ( channel , matchedUsers , category , difficulty ) ;
87
87
return true ;
88
88
}
89
89
}
@@ -102,16 +102,18 @@ function removeMatchedUsersFromOtherLists(matchedUsers, keyToSkip) {
102
102
console . log ( "waiting users after removing: " , waitingUsers ) ;
103
103
}
104
104
105
- async function notifyMatch ( channel , matchedUsers , category ) {
105
+ async function notifyMatch ( channel , matchedUsers , category , complexity ) {
106
106
const roomId = uuidv4 ( ) ;
107
107
108
108
try {
109
109
// Fetch a question from QuestionService based on category
110
- const response = await axios . get ( `${ questionAPIUrl } /by-category` , {
111
- params : { category : category }
110
+ console . log ( `fetching question by ${ category } ${ complexity } ` )
111
+ const response = await axios . get ( `${ questionAPIUrl } /by-category-and-complexity` , {
112
+ params : { category : category , complexity : complexity }
112
113
} ) ;
113
114
114
115
const questions = response . data ;
116
+ console . log ( "questions fetch from db: " , questions )
115
117
const randomIndex = Math . floor ( Math . random ( ) * questions . length ) ;
116
118
117
119
// Notify matched users with the roomId, question, and other details
0 commit comments