Skip to content

Commit d80ee07

Browse files
committed
feat(bench): add maxCyclomaticComplexity
1 parent 30f1492 commit d80ee07

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/benchmarks/benchmark.entity.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
import { ApiProperty } from '@nestjs/swagger';
3+
import { User } from 'src/users/user.entity';
24
import {
35
BaseEntity,
46
Column,
@@ -8,8 +10,6 @@ import {
810
OneToMany,
911
PrimaryGeneratedColumn,
1012
} from 'typeorm';
11-
import { ApiProperty } from '@nestjs/swagger';
12-
import { User } from 'src/users/user.entity';
1313
import { Submission } from '../submissions/submission.entity';
1414

1515
@Entity('benchmarks')
@@ -49,4 +49,8 @@ export class Benchmark extends BaseEntity {
4949
@ManyToOne((type) => User, (user) => user.benchmarks, { eager: true })
5050
@ApiProperty({ type: () => User })
5151
creator: User;
52+
53+
@ApiProperty()
54+
@Column({ default: 10 })
55+
maxCyclomaticComplexity: number;
5256
}

src/benchmarks/dto/create-benchmark.dto.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
21
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2+
import { IsNotEmpty, IsNumber, IsOptional, IsString } from 'class-validator';
33

44
export class CreateBenchmarkDto {
55
@IsNotEmpty()
@@ -22,4 +22,8 @@ export class CreateBenchmarkDto {
2222
@IsString()
2323
@ApiProperty()
2424
difficulty: string;
25+
26+
@IsNotEmpty()
27+
@IsNumber()
28+
maxCyclomaticComplexity: number;
2529
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {MigrationInterface, QueryRunner} from "typeorm";
2+
3+
export class AddBenchMaxComplexity1627494323643 implements MigrationInterface {
4+
name = 'AddBenchMaxComplexity1627494323643'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`ALTER TABLE "benchmarks" ADD "maxCyclomaticComplexity" integer NOT NULL DEFAULT '10'`);
8+
}
9+
10+
public async down(queryRunner: QueryRunner): Promise<void> {
11+
await queryRunner.query(`ALTER TABLE "benchmarks" DROP COLUMN "maxCyclomaticComplexity"`);
12+
}
13+
14+
}

0 commit comments

Comments
 (0)