@@ -7,14 +7,15 @@ import {
7
7
} from '@nestjs/common' ;
8
8
import { InjectRepository } from '@nestjs/typeorm' ;
9
9
import { TypedJSON } from 'typedjson' ;
10
- import { Repository } from 'typeorm' ;
10
+ import { IsNull , Not , Repository } from 'typeorm' ;
11
11
import { BenchmarkService } from '../benchmarks/benchmark.service' ;
12
12
import { User } from '../users/user.entity' ;
13
13
import { FindLastSubmissionByLanguageDTO } from './dto/find-last-submission-by-language.dto' ;
14
14
import { FindSubmissionDTO } from './dto/find-submission.dto' ;
15
15
import { InsertSubmissionDTO } from './dto/insert-submission-dto' ;
16
16
import { JobStatusDTO } from './dto/job-status.dto' ;
17
17
import { Submission } from './submission.entity' ;
18
+ import { BenchmarkIdDto } from '../benchmarks/dto/benchmarkId.dto' ;
18
19
19
20
@Injectable ( )
20
21
export class SubmissionsService {
@@ -138,6 +139,21 @@ export class SubmissionsService {
138
139
}
139
140
}
140
141
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
+
141
157
async findLastByLanguage (
142
158
filter : FindLastSubmissionByLanguageDTO ,
143
159
requestUser : User ,
0 commit comments