Skip to content

Commit

Permalink
Pass judger in docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
slhmy committed Feb 8, 2024
1 parent 239e022 commit f7d900b
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 20 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ dist.zip

# Ignore generated files
*.pb.go
**/swaggo-gen/docs.go
**/swaggo-gen/docs.go

environment/rclone-minio.conf
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
"postman": "api",
".github/workflows": "github",
"test-collection": "resource"
}
},
"go.testFlags": [
"-v",
"-count=1"
],
}
15 changes: 8 additions & 7 deletions environment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ services:
ports:
- "6379:6379"

judger-1:
judger:
image: ghcr.io/oj-lab/judger/judger-server:main
pull_policy: always
restart: always
ports:
- "8000:8000"

judger-2:
image: ghcr.io/oj-lab/judger/judger-server:main
restart: always
ports:
- "8001:8000"
environment:
- BASE_URL=http://host.docker.internal:8080/api/v1/judge
- INTERVAL=10
- RUST_LOG=DEBUG
volumes:
- ../environment/rclone-minio.conf:/workspace/data/rclone-minio.conf
9 changes: 9 additions & 0 deletions environment/rclone-minio.example.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[minio]
type = s3
provider = Minio
env_auth = false
access_key_id = your_access_key_id
secret_access_key = your_access_key_id
endpoint = http://host.docker.internal:9000
location_constraint =
acl = private
6 changes: 3 additions & 3 deletions src/application/migrate_db/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
Title: "Hello World!",
Description: &description,
Tags: []*model.AlgorithmTag{
{Slug: "primer", Name: "Primer"},
{Name: "Primer"},
},
})

Expand All @@ -30,8 +30,8 @@ func main() {
Title: "A + B",
Description: &description,
Tags: []*model.AlgorithmTag{
{Slug: "primer", Name: "Primer"},
{Slug: "math", Name: "Math"},
{Name: "Primer"},
{Name: "Math"},
},
})

Expand Down
6 changes: 3 additions & 3 deletions src/service/mapper/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ type GetProblemOptions struct {
func buildGetProblemTXByOptions(tx *gorm.DB, options GetProblemOptions, isCount bool) *gorm.DB {
tagsList := []string{}
for _, tag := range options.Tags {
tagsList = append(tagsList, tag.Slug)
tagsList = append(tagsList, tag.Name)
}
tx = tx.Model(&model.Problem{})
if len(options.Selection) > 0 {
tx = tx.Select(options.Selection)
}
if len(tagsList) > 0 {
tx = tx.Joins("JOIN problem_algorithm_tags ON problem_algorithm_tags.problem_slug = problems.slug").
Where("problem_algorithm_tags.algorithm_tag_slug in ?", tagsList)
Where("problem_algorithm_tags.algorithm_tag_name in ?", tagsList)
}
if options.Slug != nil {
tx = tx.Where("slug = ?", *options.Slug)
Expand Down Expand Up @@ -98,7 +98,7 @@ func GetProblemListByOptions(tx *gorm.DB, options GetProblemOptions) ([]model.Pr
func GetTagsList(problem model.Problem) []string {
tagsList := []string{}
for _, tag := range problem.Tags {
tagsList = append(tagsList, tag.Slug)
tagsList = append(tagsList, tag.Name)
}
return tagsList
}
3 changes: 1 addition & 2 deletions src/service/model/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ type Problem struct {

type AlgorithmTag struct {
MetaFields
Slug string `gorm:"primaryKey" json:"slug"`
Name string `gorm:"not null" json:"name"`
Name string `gorm:"primaryKey" json:"name"`
Problems []*Problem `gorm:"many2many:problem_algorithm_tags;" json:"problems,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion tests/core/minio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestMinio(T *testing.T) {
}

// Upload package files
packagePath := "tests/data/packages/icpc/hello_world"
packagePath := "../data/packages/icpc/hello-world"
filepath.Walk(packagePath, func(path string, info fs.FileInfo, err error) error {
if info == nil {
return fmt.Errorf("file info is nil")
Expand Down
4 changes: 2 additions & 2 deletions tests/mapper/problem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestProblemMapper(t *testing.T) {
Slug: "a-plus-b-problem",
Title: "A+B Problem",
Description: &description,
Tags: []*model.AlgorithmTag{{Slug: "tag1"}, {Slug: "tag2"}},
Tags: []*model.AlgorithmTag{{Name: "tag1"}, {Name: "tag2"}},
}

err := mapper.CreateProblem(db, problem)
Expand All @@ -38,7 +38,7 @@ func TestProblemMapper(t *testing.T) {

problemOption := mapper.GetProblemOptions{
Selection: model.ProblemInfoSelection,
Tags: []*model.AlgorithmTag{{Slug: "tag1"}},
Tags: []*model.AlgorithmTag{{Name: "tag1"}},
Slug: &problem.Slug,
}

Expand Down

0 comments on commit f7d900b

Please sign in to comment.