Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutgon committed Sep 19, 2024
1 parent 746be45 commit caf8ca7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ export default async function ConnectedEvaluationLayout({
projectId: Number(params.projectId),
uuid: params.commitUuid,
})

const aggregationTotals = await getEvaluationTotalsQuery({
workspaceId: workspace.id,
documentUuid: params.documentUuid,
evaluation,
commit,
})

const evaluationResults = await computeEvaluationResultsWithMetadata({
workspaceId: evaluation.workspaceId,
evaluation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
import { and, avg, eq, isNotNull, or, sum } from 'drizzle-orm'

import { Commit, Evaluation } from '../../../browser'
import { database } from '../../../client'
import { DocumentLogsRepository, EvaluationResultsRepository } from '../../../repositories'
import { commits } from '../../../schema'

export async function getEvaluationMeanValueQuery(
{
workspaceId,
evaluation,
documentUuid,
commit,
}: {
workspaceId: number
evaluation: Evaluation
documentUuid: string
commit: Commit
},
db = database,
) {
const { scope: evaluationResultsScope } = new EvaluationResultsRepository(
workspaceId,
db,
)
const { scope: documentLogsScope } = new DocumentLogsRepository(
workspaceId,
db,
)


export async function getEvaluationMeanValueQuery({
workspaceId,
evaluation,
documentUuid,
commit,
}: {
workspaceId: number
evaluation: Evaluation
documentUuid: string
commit: Commit
}) {
const results = await db
.select({
meanValue: avg(evaluationResultsScope.result)
.mapWith(Number)
.as('meanValue'),
})
.from(evaluationResultsScope)
.innerJoin(commits, eq(commits.id, documentLogsScope.commitId))
.innerJoin(
documentLogsScope,
eq(documentLogsScope.id, evaluationResultsScope.documentLogId),
)
.where(
and(
eq(evaluationResultsScope.evaluationId, evaluation.id),
eq(evaluationResultsScope.documentUuid, documentUuid),
eq(evaluationResultsScope.commitId, commit.id),
),
)
}

0 comments on commit caf8ca7

Please sign in to comment.