Skip to content

Commit

Permalink
feat(submissions): separate stdout/stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
angristan committed Jun 7, 2021
1 parent 9212b67 commit f308673
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/migrations/1623077854175-AddStdErrStdOut.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class AddStdErrStdOut1623077854175 implements MigrationInterface {
name = 'AddStdErrStdOut1623077854175'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "submissions" DROP COLUMN "output"`);
await queryRunner.query(`ALTER TABLE "submissions" ADD "stdout" character varying`);
await queryRunner.query(`ALTER TABLE "submissions" ADD "stderr" character varying`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "submissions" DROP COLUMN "stderr"`);
await queryRunner.query(`ALTER TABLE "submissions" DROP COLUMN "stdout"`);
await queryRunner.query(`ALTER TABLE "submissions" ADD "output" character varying`);
}

}
6 changes: 5 additions & 1 deletion src/submissions/submission.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export class Submission extends BaseEntity {

@jsonMember
@Column({ nullable: true })
output: string;
stdout: string;

@jsonMember
@Column({ nullable: true })
stderr: string;

@jsonMember
@ApiProperty()
Expand Down
10 changes: 7 additions & 3 deletions src/submissions/submissions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ export class SubmissionsService {
async setStatus(
id: string,
status: string,
output?: string,
stdout?: string,
stderr?: string,
): Promise<Submission | undefined> {
const submission = await this.submissionsRepository.findOne({
id,
});
if (submission) {
submission.status = status;
if (output) {
submission.output = output;
if (stdout) {
submission.stdout = stdout;
}
if (stderr) {
submission.stderr = stderr;
}
await submission.save();
return submission;
Expand Down

0 comments on commit f308673

Please sign in to comment.