Skip to content

Commit 62a10ce

Browse files
committed
fix type error
1 parent 0920e9d commit 62a10ce

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

server/src/functions/engines/recommendation.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { recommend as sql } from "@prisma/client/sql";
22
import { 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";
44
import { prisma } from "../../database/client";
5-
import { getUserByID } from "../../database/users";
65

76
export 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))

0 commit comments

Comments
 (0)