From 081d74f1c3eda4b13fc9accf9dd22b8d9b0125bd Mon Sep 17 00:00:00 2001 From: Menci Date: Mon, 24 Jun 2019 18:58:26 +0800 Subject: [PATCH] Fix CE submissions' score is NULL --- models/common.ts | 3 +++ models/judge_state.ts | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/models/common.ts b/models/common.ts index 9eaa15c..5a1dc7a 100644 --- a/models/common.ts +++ b/models/common.ts @@ -86,7 +86,10 @@ export default class Model extends TypeORM.BaseEntity { } } + async saveHook(): Promise {} + async save(): Promise { + await this.saveHook(); await super.save(); if ((this.constructor as typeof Model).cache) { cacheSet(this.constructor.name, (this as any).id, this); diff --git a/models/judge_state.ts b/models/judge_state.ts index ad7868a..065f67f 100644 --- a/models/judge_state.ts +++ b/models/judge_state.ts @@ -97,7 +97,7 @@ export default class JudgeState extends Model { @TypeORM.Column({ nullable: true, type: "integer" }) type_info: number; - + @TypeORM.Index() @TypeORM.Column({ nullable: true, type: "boolean" }) is_public: boolean; @@ -114,6 +114,10 @@ export default class JudgeState extends Model { } } + async saveHook() { + if (this.score === null) this.score = 0; + } + async isAllowedVisitBy(user) { await this.loadRelationships();