Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(ui): add org constraint to author user query on scores table (#2918)

Marc Klingenafec6fb433e5
diff --git a/web/src/components/table/use-cases/scores.tsx b/web/src/components/table/use-cases/scores.tsx
index 2a1d7f1da0..5ef278bf9c 100644
--- a/web/src/components/table/use-cases/scores.tsx
+++ b/web/src/components/table/use-cases/scores.tsx
@@ -34,6 +34,7 @@ export type ScoresTableRow = {
dataType: ScoreDataType;
value: string;
author: {
+ userId?: string;
image?: string;
name?: string;
};
@@ -283,7 +284,7 @@ export default function ScoresTable({
enableHiding: true,
size: 150,
cell: ({ row }) => {
- const { name, image } = row.getValue(
+ const { userId, name, image } = row.getValue(
"author",
) as ScoresTableRow["author"];
return (
@@ -294,7 +295,7 @@ export default function ScoresTable({
alt={name ?? "User Avatar"}
/>
</Avatar>
- <span>{name}</span>
+ <span>{name ?? userId}</span>
</div>
);
},
@@ -347,6 +348,7 @@ export default function ScoresTable({
: score.value.toFixed(4)
: score.stringValue ?? "",
author: {
+ userId: score.authorUserId ?? undefined,
image: score.authorUserImage ?? undefined,
name: score.authorUserName ?? undefined,
},
diff --git a/web/src/server/api/routers/scores.ts b/web/src/server/api/routers/scores.ts
index a3993aadc5..2821f34a98 100644
--- a/web/src/server/api/routers/scores.ts
+++ b/web/src/server/api/routers/scores.ts
@@ -81,6 +81,7 @@ export const scoresRouter = createTRPCRouter({
u.name AS "authorUserName"
`,
input.projectId,
+ ctx.session.orgId,
filterCondition,
orderByCondition,
input.limit,
@@ -94,6 +95,7 @@ export const scoresRouter = createTRPCRouter({
generateScoresQuery(
Prisma.sql` count(*) AS "totalCount"`,
input.projectId,
+ ctx.session.orgId,
filterCondition,
Prisma.empty,
1, // limit
@@ -347,6 +349,7 @@ export const scoresRouter = createTRPCRouter({
const generateScoresQuery = (
select: Prisma.Sql,
projectId: string,
+ orgId: string,
filterCondition: Prisma.Sql,
orderCondition: Prisma.Sql,
limit: number,
@@ -358,7 +361,7 @@ const generateScoresQuery = (
FROM scores s
LEFT JOIN traces t ON t.id = s.trace_id AND t.project_id = ${projectId}
LEFT JOIN job_executions je ON je.job_output_score_id = s.id AND je.project_id = ${projectId}
- LEFT JOIN users u ON u.id = s.author_user_id
+ LEFT JOIN users u ON u.id = s.author_user_id AND u.id in (SELECT user_id FROM organization_memberships WHERE org_id = ${orgId})
WHERE s.project_id = ${projectId}
${filterCondition}
${orderCondition}