Skip to content

Commit

Permalink
Fast forward master to issue23 (#25)
Browse files Browse the repository at this point in the history
* feat(Testsuit): ✨ make testsuit an cli application instead of a collection of rstest
* fix(Testsuit): 🐛 bring nighty frontend
* feat(Testsuit): ✅ add create and add_to test
* test(Testsuit): 🧪 lua RE: wrong test input
* fix(Judger): 🐛 change return code form 1 to 0
* feat(Backend): ✨ auto generate config and database folder
* cargo clippy
  • Loading branch information
Eason0729 authored Jan 28, 2024
1 parent 6b2fde5 commit dc04477
Show file tree
Hide file tree
Showing 56 changed files with 907 additions and 323 deletions.
151 changes: 83 additions & 68 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ prost = "0.12.3"
prost-types = "0.12.3"
tonic-build = "0.10.2"
tonic-web = "0.10.2"
serde = "1.0.163"
toml = "0.7.4"

[workspace.dependencies.tonic]
version = "0.10.2"
Expand Down
19 changes: 9 additions & 10 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tikv-jemallocator = "0.5"
log = "0.4.18"
paste = "1.0.12"
prost = { workspace = true }
toml = "0.7.4"
toml = { workspace = true }
prost-types = { workspace = true }
# entity = { path = "./entity" }
chrono = "0.4.26"
Expand Down Expand Up @@ -38,6 +38,8 @@ opentelemetry_sdk = { version = "0.21.1", features = ["rt-tokio", "metrics"] }
opentelemetry-stdout = { version = "0.2.0", features = ["metrics"] }
opentelemetry-semantic-conventions = "0.13.0"
opentelemetry-otlp = { version = "0.14.0", features = ["metrics"] }
migration = { path = "./migration" }
sea-orm-cli = "0.12.12"

[dependencies.reqwest]
version = "0.11.22"
Expand Down Expand Up @@ -76,7 +78,7 @@ features = [
]

[dependencies.serde]
version = "1.0.163"
workspace = true
features = ["derive"]

[dependencies.tonic]
Expand All @@ -87,19 +89,16 @@ features = ["transport", "channel", "codegen", "prost","tls"]
version = "0.9.8"
features = ["mutex", "spin_mutex", "rwlock"]

[dev-dependencies]
migration = { path = "./migration" }
sea-orm-cli = "0.12.12"

[dev-dependencies.sea-orm-migration]
[dependencies.sea-orm-migration]
workspace = true
features = [
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
# e.g.
"runtime-tokio-native-tls",
"sqlx-sqlite","with-chrono"
]

[build-dependencies]
tonic-build = { workspace = true }

[features]
default = []
standalone = []
20 changes: 20 additions & 0 deletions backend/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
```toml
bind_address = "0.0.0.0:8081"
log_level = 0
opentelemetry = false

[database]
path = "database/backend.sqlite"
salt = "be sure to change it"

[[judger]]
name = "http://127.0.0.1:8080"
type = "static"

[grpc]

[imgur]
client_id = "fffffffffffffff"
client_secret = "ffffffffffffffffffffffffffffffffffffffff"

```
8 changes: 4 additions & 4 deletions backend/src/endpoint/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ impl SubmitSet for Arc<Server> {
let (auth, req) = self.parse_request(req).await?;
let (user_id, _) = auth.ok_or_default()?;

if req.info.code.len() > SUBMIT_CODE_LEN {
if req.code.len() > SUBMIT_CODE_LEN {
return Err(Error::BufferTooLarge("info.code").into());
}

let lang = Uuid::parse_str(req.info.lang.as_str()).map_err(Into::<Error>::into)?;
let lang = Uuid::parse_str(req.lang.as_str()).map_err(Into::<Error>::into)?;

let problem = problem::Entity::find_by_id(req.info.problem_id)
let problem = problem::Entity::find_by_id(req.problem_id)
.one(db)
.await
.map_err(Into::<Error>::into)?
Expand All @@ -172,7 +172,7 @@ impl SubmitSet for Arc<Server> {
}

let submit = SubmitBuilder::default()
.code(req.info.code)
.code(req.code)
.lang(lang)
.time_limit(problem.time)
.memory_limit(problem.memory)
Expand Down
3 changes: 1 addition & 2 deletions backend/src/entity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use sea_orm::{
entity::prelude::*,
EntityTrait, FromQueryResult, PrimaryKeyTrait, QueryFilter, Select,
entity::prelude::*, EntityTrait, FromQueryResult, PrimaryKeyTrait, QueryFilter, Select,
};

use sea_orm::ColumnTrait;
Expand Down
Loading

0 comments on commit dc04477

Please sign in to comment.