@@ -3,7 +3,6 @@ import type { IMatchItemsResponse, IMatchType } from '@/types';
3
3
4
4
import { createRoom } from './collab' ;
5
5
import { getRandomQuestion } from './question' ;
6
- import { fetchAttemptedQuestions } from './user' ;
7
6
8
7
export async function getMatchItems (
9
8
searchIdentifier : IMatchType ,
@@ -17,26 +16,13 @@ export async function getMatchItems(
17
16
throw new Error ( 'Both user IDs are required' ) ;
18
17
}
19
18
20
- let allAttemptedQuestions : number [ ] = [ ] ;
21
-
22
- try {
23
- const [ attemptedQuestions1 , attemptedQuestions2 ] = await Promise . all ( [
24
- fetchAttemptedQuestions ( userId1 ) ,
25
- fetchAttemptedQuestions ( userId2 ) ,
26
- ] ) ;
27
- allAttemptedQuestions = [ ...new Set ( [ ...attemptedQuestions1 , ...attemptedQuestions2 ] ) ] ;
28
- } catch ( error ) {
29
- logger . error ( 'Error in getMatchItems: Failed to fetch attempted questions' , error ) ;
30
- }
31
-
32
19
const topics = topic ?. split ( '|' ) ?? [ ] ;
33
20
const payload = {
34
- attemptedQuestions : allAttemptedQuestions ,
21
+ userId1,
22
+ userId2,
35
23
...( searchIdentifier === 'difficulty' && difficulty ? { difficulty } : { } ) ,
36
- ...( searchIdentifier === 'topic' && topic ? { topic : topics } : { } ) ,
37
- ...( searchIdentifier === 'exact match' && topic && difficulty
38
- ? { topic : topics , difficulty }
39
- : { } ) ,
24
+ ...( searchIdentifier === 'topic' && topic ? { topics } : { } ) ,
25
+ ...( searchIdentifier === 'exact match' && topic && difficulty ? { topics, difficulty } : { } ) ,
40
26
} ;
41
27
42
28
// Get a random question
@@ -55,7 +41,8 @@ export async function getMatchItems(
55
41
questionId : question . id ,
56
42
} ;
57
43
} catch ( error ) {
58
- logger . error ( 'Error in getMatchItems:' , error ) ;
44
+ const { name, message, stack, cause } = error as Error ;
45
+ logger . error ( `Error in getMatchItems: ${ JSON . stringify ( { name, message, stack, cause } ) } ` ) ;
59
46
return undefined ;
60
47
}
61
48
}
0 commit comments