Commit 77cf825b authored by Robert Czechowski's avatar Robert Czechowski

Fix contest grade calculation in contest view: Division by zero could occur...

Fix contest grade calculation in contest view: Division by zero could occur for empty contests after they have been started
parent 4e16dca1
Pipeline #1183 failed with stages
in 8 minutes and 39 seconds
......@@ -442,7 +442,7 @@ pub fn show_contest<T: MedalConnection>(conn: &T, contest_id: i32, session_token
totalgrade += grade.grade.unwrap_or(0);
max_totalgrade += taskgroup.tasks.iter().map(|x| x.stars).max().unwrap_or(0);
}
let relative_points = (totalgrade * 100) / max_totalgrade;
let relative_points = if max_totalgrade > 0 { (totalgrade * 100) / max_totalgrade } else { 0 };
data.insert("tasks".to_string(), to_json(&tasks));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment