@@ -7,14 +7,15 @@ import {
77} from '@nestjs/common' ;
88import { InjectRepository } from '@nestjs/typeorm' ;
99import { TypedJSON } from 'typedjson' ;
10- import { Repository } from 'typeorm' ;
10+ import { IsNull , Not , Repository } from 'typeorm' ;
1111import { BenchmarkService } from '../benchmarks/benchmark.service' ;
1212import { User } from '../users/user.entity' ;
1313import { FindLastSubmissionByLanguageDTO } from './dto/find-last-submission-by-language.dto' ;
1414import { FindSubmissionDTO } from './dto/find-submission.dto' ;
1515import { InsertSubmissionDTO } from './dto/insert-submission-dto' ;
1616import { JobStatusDTO } from './dto/job-status.dto' ;
1717import { Submission } from './submission.entity' ;
18+ import { BenchmarkIdDto } from '../benchmarks/dto/benchmarkId.dto' ;
1819
1920@Injectable ( )
2021export class SubmissionsService {
@@ -138,6 +139,21 @@ export class SubmissionsService {
138139 }
139140 }
140141
142+ async getLeaderboardForBenchmark (
143+ benchmarkId : BenchmarkIdDto ,
144+ ) : Promise < Submission [ ] > {
145+ const bench = await this . benchmarkService . findOne ( benchmarkId . id ) ;
146+ return this . submissionsRepository . find ( {
147+ where : [
148+ {
149+ benchmark : bench ,
150+ qualityScore : Not ( IsNull ( ) ) ,
151+ } ,
152+ ] ,
153+ order : { qualityScore : 'DESC' } ,
154+ } ) ;
155+ }
156+
141157 async findLastByLanguage (
142158 filter : FindLastSubmissionByLanguageDTO ,
143159 requestUser : User ,
0 commit comments