Skip to content

Commit

Permalink
Merge branch 'main' into feat/org
Browse files Browse the repository at this point in the history
  • Loading branch information
K0nnyaku committed Dec 24, 2024
2 parents a1cd4ff + 48edf26 commit 27fe24e
Show file tree
Hide file tree
Showing 9 changed files with 683 additions and 26 deletions.
5 changes: 0 additions & 5 deletions .changes/solution.md

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
push:
branches:
- main
paths:
- "src/"
- "tests/"
pull_request:
branches:
- main
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## \[0.1.17]

### New Features

- [`5ac5d25`](https://github.com/swpu-acm/online-judge/commit/5ac5d2524eeea91ce31a0169108229c510ffd776) ([#61](https://github.com/swpu-acm/online-judge/pull/61) by [@K0nnyaku](https://github.com/swpu-acm/online-judge/../../K0nnyaku)) Support create, delete, get, list, update solutions

### Chores

- [`886474e`](https://github.com/swpu-acm/online-judge/commit/886474e4bca334405888c160089e9c24ee26459e) ([#67](https://github.com/swpu-acm/online-judge/pull/67) by [@K0nnyaku](https://github.com/swpu-acm/online-judge/../../K0nnyaku)) remove map_err

## \[0.1.16]

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "algohub-server"
version = "0.1.16"
version = "0.1.17"
edition = "2021"
description = "Extremely fast async online judge backend based on Rust"
readme = "README.md"
Expand Down
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/routes/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ pub async fn login(
login: Json<Login<'_>>,
) -> Result<OwnedCredentials> {
let session = session::authenticate(db, login.identity, login.password)
.await
.map_err(|e| Error::ServerError(Json(e.to_string().into())))?
.await?
.ok_or(Error::Unauthorized(Json("Invalid credentials".into())))?;
Ok(Response {
success: true,
Expand Down
7 changes: 2 additions & 5 deletions src/routes/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ pub async fn create(
}

let data = category::create(db, category.into_inner().data)
.await
.map_err(|e| Error::ServerError(Json(e.to_string().into())))?
.await?
.ok_or(Error::ServerError(Json("Failed to create category".into())))?;

Ok(Json(Response {
Expand All @@ -48,9 +47,7 @@ pub async fn delete(
)));
}

category::delete(db, id)
.await
.map_err(|e| Error::ServerError(Json(e.to_string().into())))?;
category::delete(db, id).await?;

Ok(Response {
success: true,
Expand Down
9 changes: 2 additions & 7 deletions src/routes/organization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,8 @@ pub async fn delete(
)));
}

organization::delete(db, id)
.await
.map_err(|e| Error::ServerError(Json(e.to_string().into())))?;

remove_dir_all(Path::new("content/").join(id))
.await
.map_err(|e| Error::ServerError(Json(e.to_string().into())))?;
organization::delete(db, id).await?;
remove_dir_all(Path::new("content/").join(id)).await?;

Ok(Response {
success: true,
Expand Down
9 changes: 3 additions & 6 deletions src/routes/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ pub async fn create(
}

let problem = problem::create(db, problem.into_inner())
.await
.map_err(|e| Error::ServerError(Json(e.to_string().into())))?
.await?
.ok_or(Error::ServerError(Json(
"Failed to create problem, please try again later.".into(),
)))?;
Expand All @@ -52,8 +51,7 @@ pub async fn get(
auth: Json<Option<Credentials<'_>>>,
) -> Result<UserProblem> {
let problem = problem::get::<Problem>(db, id)
.await
.map_err(|e| Error::ServerError(Json(e.to_string().into())))?
.await?
.ok_or(Error::NotFound(Json(
"Problem with specified id not found".into(),
)))?;
Expand Down Expand Up @@ -157,8 +155,7 @@ pub async fn update(
}

problem::update(db, id, problem.into_inner())
.await
.map_err(|e| Error::ServerError(Json(e.to_string().into())))?
.await?
.ok_or(Error::ServerError(Json(
"Failed to update problem, please try again later.".into(),
)))?;
Expand Down

0 comments on commit 27fe24e

Please sign in to comment.