File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
server/src/functions/engines Expand file tree Collapse file tree 1 file changed +6
-6
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 { UserID , UserWithCoursesAndSubjects } from "common/types" ;
3+ import type { User , UserID , UserWithCoursesAndSubjects } from "common/types" ;
44import { prisma } from "../../database/client" ;
5- import { getUserByID } from "../../database/users" ;
65
76export async function recommendedTo (
87 user : UserID ,
@@ -11,18 +10,19 @@ export async function recommendedTo(
1110) : Promise <
1211 Result <
1312 Array < {
14- u : UserWithCoursesAndSubjects ;
15- overlap : number ;
13+ u : User ; // UserWithCoursesAndSubjects
14+ count : number ;
1615 } >
1716 >
1817> {
1918 try {
2019 const result = await prisma . $queryRawTyped ( sql ( user , limit , offset ) ) ;
2120 return Promise . all (
2221 result . map ( async ( res ) => {
23- if ( ! res ) throw new Error ( "res is null: something is wrong" ) ;
2422 const { overlap : count , ...u } = res ;
25- return { count, u } ;
23+ if ( count === null )
24+ throw new Error ( "count is null: something is wrong" ) ;
25+ return { count : Number ( count ) , u } ;
2626 } ) ,
2727 )
2828 . then ( ( val ) => Ok ( val ) )
You can’t perform that action at this time.
0 commit comments