Skip to content

Commit

Permalink
fix evaluations query to write the label to the correct evaluation (#176
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dinmukhamedm authored Nov 8, 2024
1 parent d97d13c commit 96f9a13
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,20 @@ export async function POST(request: Request, { params }: { params: { projectId:
await db.insert(evaluationScores).values(evaluationValues);

if (isFeatureEnabled(Feature.FULL_BUILD)) {
const evaluation = await db.query.evaluations.findFirst({
with: {
evaluationResults: {
where: eq(evaluationResults.id, resultId)
}
}
});
if (evaluation && evaluationValues.length > 0) {
const result = await clickhouseClient.insert({
// TODO: optimize this query to use subquery instead of join.
const matchingEvaluations = await db
.select()
.from(evaluations)
.innerJoin(evaluationResults, eq(evaluationResults.evaluationId, evaluations.id))
.where(and(
eq(evaluationResults.id, resultId),
eq(evaluations.projectId, params.projectId)
))
.limit(1);

if (matchingEvaluations.length > 0) {
const evaluation = matchingEvaluations[0].evaluations;
await clickhouseClient.insert({
table: 'evaluation_scores',
format: 'JSONEachRow',
values: evaluationValues.map(value => ({
Expand Down

0 comments on commit 96f9a13

Please sign in to comment.