File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
server/src/functions/engines Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 11import { recommend as sql } from "@prisma/client/sql" ;
22import { Err , Ok , type Result } from "common/lib/result" ;
3- import type { User , UserID , UserWithCoursesAndSubjects } from "common/types" ;
3+ import type { UserID , UserWithCoursesAndSubjects } from "common/types" ;
44import { prisma } from "../../database/client" ;
5+ import { getCoursesByUserId } from "../../database/courses" ;
6+ import * as interest from "../../database/interest" ;
57
68export async function recommendedTo (
79 user : UserID ,
@@ -10,7 +12,7 @@ export async function recommendedTo(
1012) : Promise <
1113 Result <
1214 Array < {
13- u : User ; // UserWithCoursesAndSubjects
15+ u : UserWithCoursesAndSubjects ;
1416 count : number ;
1517 } >
1618 >
@@ -22,7 +24,16 @@ export async function recommendedTo(
2224 const { overlap : count , ...u } = res ;
2325 if ( count === null )
2426 throw new Error ( "count is null: something is wrong" ) ;
25- return { count : Number ( count ) , u } ;
27+ const courses = getCoursesByUserId ( u . id ) ;
28+ const subjects = interest . of ( u . id ) ;
29+ return {
30+ count : Number ( count ) ,
31+ u : {
32+ ...u ,
33+ courses : await courses ,
34+ interestSubjects : await subjects ,
35+ } ,
36+ } ;
2637 } ) ,
2738 )
2839 . then ( ( val ) => Ok ( val ) )
You can’t perform that action at this time.
0 commit comments