Skip to content

Commit

Permalink
fix(submission source code): show submission source code iff problem …
Browse files Browse the repository at this point in the history
…has been solved previously by user
  • Loading branch information
WarriorsSami committed May 8, 2024
1 parent b111652 commit 7b60949
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub struct GetHighestScoreSubmissionDto {

impl From<(Submission, Problem)> for GetHighestScoreSubmissionDto {
fn from((submission, problem): (Submission, Problem)) -> Self {

Self {
id: submission.id().to_string(),
problem_id: submission.problem_id().to_string(),
Expand Down
2 changes: 1 addition & 1 deletion anubis-eval/src/contracts/get_submission_dtos.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::domain::problem::Problem;
use crate::domain::submission::Submission;
use chrono::{DateTime, Utc};
use rocket::serde::Serialize;
use crate::domain::problem::Problem;

#[derive(Serialize)]
#[serde(crate = "rocket::serde")]
Expand Down
5 changes: 3 additions & 2 deletions anubis-eval/src/domain/submission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ impl Submission {
// user has solved the problem or is submission owner or is problem proposer
let user_has_solved_problem = Submission::is_problem_solved_by_user(
&user_id.to_string(),
self.problem_id.to_string(),
&self.problem_id.to_string(),
conn,
);
user_has_solved_problem || self.user_id == *user_id || self.user_id == *proposer_id

user_has_solved_problem || self.user_id == *user_id || user_id == proposer_id
}

pub fn id(&self) -> Uuid {
Expand Down
4 changes: 2 additions & 2 deletions anubis-eval/src/infrastructure/submission_repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Submission {
.into_iter()
.map(|(_, testcase)| testcase.into())
.collect::<Vec<TestCase>>();

testcases.sort_by_key(|a| a.testcase_id());

Ok((
Expand Down Expand Up @@ -301,7 +301,7 @@ impl Submission {

pub fn is_problem_solved_by_user(
user_id: &String,
problem_id: String,
problem_id: &String,
conn: &mut PgConnection,
) -> bool {
use crate::schema::submissions::dsl::{
Expand Down

0 comments on commit 7b60949

Please sign in to comment.