From d69293553aeaf7e9372211638b3d30aaf9580585 Mon Sep 17 00:00:00 2001 From: Tannatee Juchan Date: Sat, 8 Jun 2024 18:03:53 +0700 Subject: [PATCH 1/3] feat: add `autoTrim` option in to struct --- domain/assignment.go | 27 ++++++++++++++------------- platform/amqp/message.go | 5 +++-- platform/amqp/publisher/grading.go | 5 +++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/domain/assignment.go b/domain/assignment.go index 6379853..f7fd354 100644 --- a/domain/assignment.go +++ b/domain/assignment.go @@ -30,19 +30,20 @@ const ( ) type Assignment struct { - Id int `json:"id" db:"id"` - WorkspaceId int `json:"-" db:"workspace_id"` - Name string `json:"name" db:"name"` - Description string `json:"description" db:"description"` - DetailUrl string `json:"detailUrl" db:"detail_url"` - MemoryLimit int `json:"memoryLimit" db:"memory_limit"` - TimeLimit int `json:"timeLimit" db:"time_limit"` - Level AssignmentLevel `json:"level" db:"level"` - CreatedAt time.Time `json:"createdAt" db:"created_at"` - UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` - PublishDate time.Time `json:"publishDate" db:"publish_date"` - DueDate *time.Time `json:"dueDate" db:"due_date"` - IsDeleted bool `json:"-" db:"is_deleted"` + Id int `json:"id" db:"id"` + WorkspaceId int `json:"-" db:"workspace_id"` + Name string `json:"name" db:"name"` + Description string `json:"description" db:"description"` + DetailUrl string `json:"detailUrl" db:"detail_url"` + MemoryLimit int `json:"memoryLimit" db:"memory_limit"` + TimeLimit int `json:"timeLimit" db:"time_limit"` + Level AssignmentLevel `json:"level" db:"level"` + CreatedAt time.Time `json:"createdAt" db:"created_at"` + UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` + PublishDate time.Time `json:"publishDate" db:"publish_date"` + IsAutoTrimEnabled bool `json:"isAutoTrimEnabled" db:"is_auto_trim_enabled"` + DueDate *time.Time `json:"dueDate" db:"due_date"` + IsDeleted bool `json:"-" db:"is_deleted"` // Always aggregation Testcases []Testcase `json:"testcases"` diff --git a/platform/amqp/message.go b/platform/amqp/message.go index d9c7aa3..76b3cab 100644 --- a/platform/amqp/message.go +++ b/platform/amqp/message.go @@ -11,8 +11,9 @@ type GradeRequestMessage struct { } type GradeSettingsMessage struct { - TimeLimit int `json:"timeLimit"` - MemoryLimit int `json:"memoryLimit"` + TimeLimit int `json:"timeLimit"` + MemoryLimit int `json:"memoryLimit"` + IsAutoTrimEnabled bool `josn:"isAutoTrimEnabled"` } type GradeTestMessage struct { diff --git a/platform/amqp/publisher/grading.go b/platform/amqp/publisher/grading.go index c0402d6..4463a5a 100644 --- a/platform/amqp/publisher/grading.go +++ b/platform/amqp/publisher/grading.go @@ -61,8 +61,9 @@ func (p *gradingPublisher) Grade(assignment *domain.AssignmentWithStatus, submis SourceUrl: sourceUrl, Test: testcases, Settings: payload.GradeSettingsMessage{ - TimeLimit: assignment.TimeLimit, - MemoryLimit: assignment.MemoryLimit, + TimeLimit: assignment.TimeLimit, + MemoryLimit: assignment.MemoryLimit, + IsAutoTrimEnabled: assignment.IsAutoTrimEnabled, }, Metadata: payload.GradeMetadataMessage{ AssignmentId: assignment.Id, From ca9ab55919a5bf1f889d60472a9cfb729222f588 Mon Sep 17 00:00:00 2001 From: Tannatee Juchan Date: Sat, 8 Jun 2024 18:04:54 +0700 Subject: [PATCH 2/3] feat: assignment auto trim options --- .../000012_add-assignment-auto-trim-whitespace.down.sql | 2 ++ .../000012_add-assignment-auto-trim-whitespace.up.sql | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 other/db/migrations/000012_add-assignment-auto-trim-whitespace.down.sql create mode 100644 other/db/migrations/000012_add-assignment-auto-trim-whitespace.up.sql diff --git a/other/db/migrations/000012_add-assignment-auto-trim-whitespace.down.sql b/other/db/migrations/000012_add-assignment-auto-trim-whitespace.down.sql new file mode 100644 index 0000000..d66523c --- /dev/null +++ b/other/db/migrations/000012_add-assignment-auto-trim-whitespace.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE `assignment` +DROP `is_auto_trim_enabled`; diff --git a/other/db/migrations/000012_add-assignment-auto-trim-whitespace.up.sql b/other/db/migrations/000012_add-assignment-auto-trim-whitespace.up.sql new file mode 100644 index 0000000..0232bd6 --- /dev/null +++ b/other/db/migrations/000012_add-assignment-auto-trim-whitespace.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE `assignment` +ADD `is_auto_trim_enabled` BOOLEAN NOT NULL DEFAULT false AFTER `updated_at`; From 469643497332e8092c603779eb0f47515f1020e4 Mon Sep 17 00:00:00 2001 From: Tannatee Juchan Date: Tue, 11 Jun 2024 16:02:36 +0700 Subject: [PATCH 3/3] fix: typo json --- platform/amqp/message.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/amqp/message.go b/platform/amqp/message.go index 76b3cab..e5565e6 100644 --- a/platform/amqp/message.go +++ b/platform/amqp/message.go @@ -13,7 +13,7 @@ type GradeRequestMessage struct { type GradeSettingsMessage struct { TimeLimit int `json:"timeLimit"` MemoryLimit int `json:"memoryLimit"` - IsAutoTrimEnabled bool `josn:"isAutoTrimEnabled"` + IsAutoTrimEnabled bool `json:"isAutoTrimEnabled"` } type GradeTestMessage struct {