Commit 27ac8c89 authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Fix formatting

parent 7e788cad
Pipeline #564 canceled with stages
......@@ -181,16 +181,19 @@ pub fn show_contests<T: MedalConnection>(conn: &T, session_token: &str,
data.insert("self_url".to_string(), to_json(&self_url));
data.insert("oauth_links".to_string(), to_json(&oauth_links));
let v: Vec<ContestInfo> =
conn.get_contest_list()
.iter()
.map(|c| ContestInfo { id: c.id.unwrap(), name: c.name.clone(), duration: c.duration, public: c.public, login_required: c.requires_login.unwrap_or(false) })
.filter(|ci| ci.public || visibility == ContestVisibility::All)
.filter(|ci| ci.duration == 0 || visibility != ContestVisibility::Open)
.filter(|ci| ci.duration != 0 || visibility != ContestVisibility::Current)
.filter(|ci| ci.login_required || visibility != ContestVisibility::LoginRequired)
.filter(|ci| !ci.login_required || visibility == ContestVisibility::LoginRequired)
.collect();
let v: Vec<ContestInfo> = conn.get_contest_list()
.iter()
.map(|c| ContestInfo { id: c.id.unwrap(),
name: c.name.clone(),
duration: c.duration,
public: c.public,
login_required: c.requires_login.unwrap_or(false) })
.filter(|ci| ci.public || visibility == ContestVisibility::All)
.filter(|ci| ci.duration == 0 || visibility != ContestVisibility::Open)
.filter(|ci| ci.duration != 0 || visibility != ContestVisibility::Current)
.filter(|ci| ci.login_required || visibility != ContestVisibility::LoginRequired)
.filter(|ci| !ci.login_required || visibility == ContestVisibility::LoginRequired)
.collect();
data.insert("contest".to_string(), to_json(&v));
data.insert("contestlist_header".to_string(),
to_json(&match visibility {
......@@ -280,7 +283,7 @@ pub fn show_contest<T: MedalConnection>(conn: &T, contest_id: i32, session_token
name: contest.name.clone(),
duration: contest.duration,
public: contest.public,
login_required: contest.requires_login.unwrap_or(false)};
login_required: contest.requires_login.unwrap_or(false) };
let mut data = json_val::Map::new();
data.insert("contest".to_string(), to_json(&ci));
......@@ -419,7 +422,11 @@ pub fn show_contest_results<T: MedalConnection>(conn: &T, contest_id: i32, sessi
data.insert("result".to_string(), to_json(&results));
let c = conn.get_contest_by_id(contest_id);
let ci = ContestInfo { id: c.id.unwrap(), name: c.name.clone(), duration: c.duration, public: c.public, login_required: c.requires_login.unwrap_or(false)};
let ci = ContestInfo { id: c.id.unwrap(),
name: c.name.clone(),
duration: c.duration,
public: c.public,
login_required: c.requires_login.unwrap_or(false) };
data.insert("contest".to_string(), to_json(&ci));
data.insert("contestname".to_string(), to_json(&c.name));
......
......@@ -657,7 +657,7 @@ impl MedalConnection for Connection {
logincode: row.get(10),
firstname: row.get(11),
lastname: row.get(12),
grade: row.get(13)})
grade: row.get(13) })
})
.unwrap();
let mut gradeinfo_iter = gradeinfo.iter();
......@@ -723,9 +723,9 @@ impl MedalConnection for Connection {
ORDER BY taskgroup.positionalnumber";
let gradeinfo =
self.query_map_many(query, &[&session_token, &contest_id, &true], |row| Grade { taskgroup: row.get(0),
user: row.get(1),
grade: row.get(2),
validated: row.get(3) })
user: row.get(1),
grade: row.get(2),
validated: row.get(3) })
.unwrap();
let gradeinfo_iter = gradeinfo.iter();
......@@ -1128,7 +1128,8 @@ impl MedalConnection for Connection {
FROM participation
GROUP BY contest
ORDER BY contest DESC;";
let n_participations_by_id: Vec<(i64, i64)> = self.query_map_many(query, &[], |row| (row.get(0), row.get(1))).unwrap();
let n_participations_by_id: Vec<(i64, i64)> =
self.query_map_many(query, &[], |row| (row.get(0), row.get(1))).unwrap();
format!(
"{{
......@@ -1146,8 +1147,19 @@ impl MedalConnection for Connection {
}}
}}
",
now.sec, n_asession, n_apart, n_session, n_user, n_pmsuser, n_teacher, n_part, n_sub,
n_participations_by_id.iter().map(|(x,y)| -> String {format!("\"{}\": {}", x, y)}).collect::<Vec<String>>().join(",\n ")
now.sec,
n_asession,
n_apart,
n_session,
n_user,
n_pmsuser,
n_teacher,
n_part,
n_sub,
n_participations_by_id.iter()
.map(|(x, y)| -> String { format!("\"{}\": {}", x, y) })
.collect::<Vec<String>>()
.join(",\n ")
)
}
......
......@@ -753,7 +753,7 @@ impl MedalConnection for Connection {
logincode: row.get(10),
firstname: row.get(11),
lastname: row.get(12),
grade: row.get(13)})
grade: row.get(13) })
})
.unwrap();
let mut gradeinfo_iter = gradeinfo.iter();
......@@ -819,9 +819,9 @@ impl MedalConnection for Connection {
ORDER BY taskgroup.positionalnumber";
let gradeinfo =
self.query_map_many(query, &[&session_token, &contest_id, &true], |row| Grade { taskgroup: row.get(0),
user: row.get(1),
grade: row.get(2),
validated: row.get(3) })
user: row.get(1),
grade: row.get(2),
validated: row.get(3) })
.unwrap();
let gradeinfo_iter = gradeinfo.iter();
......@@ -1224,7 +1224,8 @@ impl MedalConnection for Connection {
FROM participation
GROUP BY contest
ORDER BY contest DESC;";
let n_participations_by_id: Vec<(i64, i64)> = self.query_map_many(query, &[], |row| (row.get(0), row.get(1))).unwrap();
let n_participations_by_id: Vec<(i64, i64)> =
self.query_map_many(query, &[], |row| (row.get(0), row.get(1))).unwrap();
format!(
"{{
......@@ -1242,8 +1243,19 @@ impl MedalConnection for Connection {
}}
}}
",
now.sec, n_asession, n_apart, n_session, n_user, n_pmsuser, n_teacher, n_part, n_sub,
n_participations_by_id.iter().map(|(x,y)| -> String {format!("\"{}\": {}", x, y)}).collect::<Vec<String>>().join(",\n ")
now.sec,
n_asession,
n_apart,
n_session,
n_user,
n_pmsuser,
n_teacher,
n_part,
n_sub,
n_participations_by_id.iter()
.map(|(x, y)| -> String { format!("\"{}\": {}", x, y) })
.collect::<Vec<String>>()
.join(",\n ")
)
}
......
......@@ -753,7 +753,7 @@ impl MedalConnection for Connection {
logincode: row.get(10),
firstname: row.get(11),
lastname: row.get(12),
grade: row.get(13)})
grade: row.get(13) })
})
.unwrap();
let mut gradeinfo_iter = gradeinfo.iter();
......@@ -819,9 +819,9 @@ impl MedalConnection for Connection {
ORDER BY taskgroup.positionalnumber";
let gradeinfo =
self.query_map_many(query, &[&session_token, &contest_id, &true], |row| Grade { taskgroup: row.get(0),
user: row.get(1),
grade: row.get(2),
validated: row.get(3) })
user: row.get(1),
grade: row.get(2),
validated: row.get(3) })
.unwrap();
let gradeinfo_iter = gradeinfo.iter();
......@@ -1224,7 +1224,8 @@ impl MedalConnection for Connection {
FROM participation
GROUP BY contest
ORDER BY contest DESC;";
let n_participations_by_id: Vec<(i64, i64)> = self.query_map_many(query, &[], |row| (row.get(0), row.get(1))).unwrap();
let n_participations_by_id: Vec<(i64, i64)> =
self.query_map_many(query, &[], |row| (row.get(0), row.get(1))).unwrap();
format!(
"{{
......@@ -1242,8 +1243,19 @@ impl MedalConnection for Connection {
}}
}}
",
now.sec, n_asession, n_apart, n_session, n_user, n_pmsuser, n_teacher, n_part, n_sub,
n_participations_by_id.iter().map(|(x,y)| -> String {format!("\"{}\": {}", x, y)}).collect::<Vec<String>>().join(",\n ")
now.sec,
n_asession,
n_apart,
n_session,
n_user,
n_pmsuser,
n_teacher,
n_part,
n_sub,
n_participations_by_id.iter()
.map(|(x, y)| -> String { format!("\"{}\": {}", x, y) })
.collect::<Vec<String>>()
.join(",\n ")
)
}
......
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