File tree Expand file tree Collapse file tree 3 files changed +35
-9
lines changed Expand file tree Collapse file tree 3 files changed +35
-9
lines changed Original file line number Diff line number Diff line change
1
+ import { MigrationInterface , QueryRunner } from "typeorm" ;
2
+
3
+ export class AddDuplicatedSubmission1626996924860 implements MigrationInterface {
4
+ name = 'AddDuplicatedSubmission1626996924860'
5
+
6
+ public async up ( queryRunner : QueryRunner ) : Promise < void > {
7
+ await queryRunner . query ( `ALTER TABLE "submissions" ADD "selfId" uuid` ) ;
8
+ await queryRunner . query ( `ALTER TABLE "submissions" ADD CONSTRAINT "FK_8cc0cfc3583dbe9e530311136f6" FOREIGN KEY ("selfId") REFERENCES "submissions"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` ) ;
9
+ }
10
+
11
+ public async down ( queryRunner : QueryRunner ) : Promise < void > {
12
+ await queryRunner . query ( `ALTER TABLE "submissions" DROP CONSTRAINT "FK_8cc0cfc3583dbe9e530311136f6"` ) ;
13
+ await queryRunner . query ( `ALTER TABLE "submissions" DROP COLUMN "selfId"` ) ;
14
+ }
15
+
16
+ }
Original file line number Diff line number Diff line change 1
1
/* eslint-disable @typescript-eslint/no-unused-vars */
2
2
import { ApiProperty } from '@nestjs/swagger' ;
3
3
import { User } from 'src/users/user.entity' ;
4
- import { jsonArrayMember , jsonMember , jsonObject } from 'typedjson' ;
4
+ import { jsonMember , jsonObject } from 'typedjson' ;
5
5
import {
6
6
BaseEntity ,
7
7
Column ,
8
8
CreateDateColumn ,
9
9
Entity ,
10
- JoinTable ,
11
- ManyToMany ,
12
10
ManyToOne ,
11
+ OneToMany ,
13
12
PrimaryGeneratedColumn ,
14
13
UpdateDateColumn ,
15
14
} from 'typeorm' ;
@@ -111,12 +110,12 @@ export class Submission extends BaseEntity {
111
110
@ApiProperty ( { type : ( ) => Benchmark } )
112
111
benchmark : Benchmark ;
113
112
114
- @ApiProperty ( )
115
- @JoinTable ( )
116
- @jsonArrayMember ( ( ) => Submission )
117
- @ManyToMany (
118
- ( ) => Submission ,
113
+ @ManyToOne (
114
+ ( type ) => Submission ,
119
115
( submission ) => submission . duplicatedSubmissions ,
120
116
)
117
+ self : Submission ;
118
+
119
+ @OneToMany ( ( type ) => Submission , ( submission ) => submission . self )
121
120
duplicatedSubmissions : Submission [ ] ;
122
121
}
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ export class SubmissionsService {
56
56
submission . benchmark ,
57
57
insertSubmissionDTO . language ,
58
58
) ;
59
+ // submission.self = submission;
59
60
60
61
return submission . save ( ) ;
61
62
}
@@ -115,7 +116,16 @@ export class SubmissionsService {
115
116
// }
116
117
117
118
// Fallback to DB
118
- return this . submissionsRepository . findOne ( { id : queriedSubmission . id } ) ;
119
+ return this . submissionsRepository . findOne ( {
120
+ where : [
121
+ {
122
+ id : queriedSubmission . id ,
123
+ } ,
124
+ ] ,
125
+ relations : [ 'duplicatedSubmissions' ] ,
126
+ order : { createdAt : 'DESC' } ,
127
+ } ) ;
128
+ // return this.submissionsRepository.findOne({ id: queriedSubmission.id });
119
129
}
120
130
121
131
@RabbitSubscribe ( {
@@ -190,6 +200,7 @@ export class SubmissionsService {
190
200
language : matchedLanguage ,
191
201
} ,
192
202
] ,
203
+ relations : [ 'duplicatedSubmissions' ] ,
193
204
order : { createdAt : 'DESC' } ,
194
205
} ) ;
195
206
}
You can’t perform that action at this time.
0 commit comments