Commit a14e3da1 authored by Robert Czechowski's avatar Robert Czechowski
Browse files

New database fields min_grade, max_grade: Add in object relation mapping

parent 06182ea7
...@@ -12,6 +12,9 @@ struct ContestYaml { ...@@ -12,6 +12,9 @@ struct ContestYaml {
duration_minutes: Option<i32>, duration_minutes: Option<i32>,
public_listing: Option<bool>, public_listing: Option<bool>,
min_grade: Option<i32>,
max_grade: Option<i32>,
tasks: Option<serde_yaml::Mapping>, tasks: Option<serde_yaml::Mapping>,
} }
...@@ -35,7 +38,9 @@ pub fn parse_yaml(content: &str, filename: &str, directory: &str) -> Option<Cont ...@@ -35,7 +38,9 @@ pub fn parse_yaml(content: &str, filename: &str, directory: &str) -> Option<Cont
config.participation_end config.participation_end
.map(|x| { .map(|x| {
strptime(&x, &"%FT%T%z").map(|t| t.to_timespec()).unwrap_or_else(|_| Timespec::new(0, 0)) strptime(&x, &"%FT%T%z").map(|t| t.to_timespec()).unwrap_or_else(|_| Timespec::new(0, 0))
})); }),
config.min_grade,
config.max_grade);
// TODO: Timeparsing should fail more pleasantly (-> Panic, thus shows message) // TODO: Timeparsing should fail more pleasantly (-> Panic, thus shows message)
for (positionalnumber, (name, info)) in config.tasks?.into_iter().enumerate() { for (positionalnumber, (name, info)) in config.tasks?.into_iter().enumerate() {
......
...@@ -614,7 +614,7 @@ impl MedalConnection for Connection { ...@@ -614,7 +614,7 @@ impl MedalConnection for Connection {
} }
fn get_contest_list(&self) -> Vec<Contest> { fn get_contest_list(&self) -> Vec<Contest> {
let query = "SELECT id, location, filename, name, duration, public, start_date, end_date let query = "SELECT id, location, filename, name, duration, public, start_date, end_date, min_grade, max_grade
FROM contest FROM contest
ORDER BY id"; ORDER BY id";
self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)), self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)),
...@@ -625,12 +625,14 @@ impl MedalConnection for Connection { ...@@ -625,12 +625,14 @@ impl MedalConnection for Connection {
public: row.get(5), public: row.get(5),
start: row.get(6), start: row.get(6),
end: row.get(7), end: row.get(7),
min_grade: row.get(8),
max_grade: row.get(9),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
.unwrap() .unwrap()
} }
fn get_contest_by_id(&self, contest_id: i32) -> Contest { fn get_contest_by_id(&self, contest_id: i32) -> Contest {
let query = "SELECT location, filename, name, duration, public, start_date, end_date let query = "SELECT location, filename, name, duration, public, start_date, end_date, min_grade, max_grade
FROM contest FROM contest
WHERE id = $1"; WHERE id = $1";
self.query_map_one(query, &[&contest_id], |row| Contest { id: Some(contest_id), self.query_map_one(query, &[&contest_id], |row| Contest { id: Some(contest_id),
...@@ -641,6 +643,8 @@ impl MedalConnection for Connection { ...@@ -641,6 +643,8 @@ impl MedalConnection for Connection {
public: row.get(4), public: row.get(4),
start: row.get(5), start: row.get(5),
end: row.get(6), end: row.get(6),
min_grade: row.get(7),
max_grade: row.get(8),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
.unwrap() .unwrap()
.unwrap() // TODO: Should return Option? .unwrap() // TODO: Should return Option?
...@@ -648,8 +652,8 @@ impl MedalConnection for Connection { ...@@ -648,8 +652,8 @@ impl MedalConnection for Connection {
fn get_contest_by_id_complete(&self, contest_id: i32) -> Contest { fn get_contest_by_id_complete(&self, contest_id: i32) -> Contest {
let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public, let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public,
contest.start_date, contest.end_date, taskgroup.id, taskgroup.name, task.id, task.location, contest.start_date, contest.end_date, contest.min_grade, contest.max_grade, taskgroup.id,
task.stars taskgroup.name, task.id, task.location, task.stars
FROM contest FROM contest
JOIN taskgroup ON contest.id = taskgroup.contest JOIN taskgroup ON contest.id = taskgroup.contest
JOIN task ON taskgroup.id = task.taskgroup JOIN task ON taskgroup.id = task.taskgroup
...@@ -665,13 +669,15 @@ impl MedalConnection for Connection { ...@@ -665,13 +669,15 @@ impl MedalConnection for Connection {
public: row.get(4), public: row.get(4),
start: row.get(5), start: row.get(5),
end: row.get(6), end: row.get(6),
min_grade: row.get(7),
max_grade: row.get(8),
taskgroups: Vec::new() }, taskgroups: Vec::new() },
Taskgroup { id: Some(row.get(7)), Taskgroup { id: Some(row.get(9)),
contest: contest_id, contest: contest_id,
name: row.get(8), name: row.get(10),
positionalnumber: None, positionalnumber: None,
tasks: Vec::new() }, tasks: Vec::new() },
Task { id: Some(row.get(9)), taskgroup: row.get(7), location: row.get(10), stars: row.get(11) }) Task { id: Some(row.get(11)), taskgroup: row.get(9), location: row.get(11), stars: row.get(13) })
}) })
.unwrap(); .unwrap();
let mut taskgroupcontest_iter = taskgroupcontest.into_iter(); let mut taskgroupcontest_iter = taskgroupcontest.into_iter();
...@@ -692,7 +698,8 @@ impl MedalConnection for Connection { ...@@ -692,7 +698,8 @@ impl MedalConnection for Connection {
fn get_contest_by_id_partial(&self, contest_id: i32) -> Contest { fn get_contest_by_id_partial(&self, contest_id: i32) -> Contest {
let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public, let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public,
contest.start_date, contest.end_date, taskgroup.id, taskgroup.name contest.start_date, contest.end_date, contest.min_grade, contest.max_grade, taskgroup.id,
taskgroup.name
FROM contest FROM contest
JOIN taskgroup ON contest.id = taskgroup.contest JOIN taskgroup ON contest.id = taskgroup.contest
WHERE contest.id = $1"; WHERE contest.id = $1";
...@@ -705,10 +712,12 @@ impl MedalConnection for Connection { ...@@ -705,10 +712,12 @@ impl MedalConnection for Connection {
public: row.get(4), public: row.get(4),
start: row.get(5), start: row.get(5),
end: row.get(6), end: row.get(6),
min_grade: row.get(7),
max_grade: row.get(8),
taskgroups: Vec::new() }, taskgroups: Vec::new() },
Taskgroup { id: Some(row.get(7)), Taskgroup { id: Some(row.get(9)),
contest: contest_id, contest: contest_id,
name: row.get(8), name: row.get(10),
positionalnumber: None, positionalnumber: None,
tasks: Vec::new() }) tasks: Vec::new() })
}) })
...@@ -770,7 +779,7 @@ impl MedalConnection for Connection { ...@@ -770,7 +779,7 @@ impl MedalConnection for Connection {
fn get_task_by_id_complete(&self, task_id: i32) -> (Task, Taskgroup, Contest) { fn get_task_by_id_complete(&self, task_id: i32) -> (Task, Taskgroup, Contest) {
let query = "SELECT task.location, task.stars, taskgroup.id, taskgroup.name, contest.id, contest.location, let query = "SELECT task.location, task.stars, taskgroup.id, taskgroup.name, contest.id, contest.location,
contest.filename, contest.name, contest.duration, contest.public, contest.start_date, contest.filename, contest.name, contest.duration, contest.public, contest.start_date,
contest.end_date contest.end_date, contest.min_grade, contest.max_grade
FROM contest FROM contest
JOIN taskgroup ON taskgroup.contest = contest.id JOIN taskgroup ON taskgroup.contest = contest.id
JOIN task ON task.taskgroup = taskgroup.id JOIN task ON task.taskgroup = taskgroup.id
...@@ -790,6 +799,8 @@ impl MedalConnection for Connection { ...@@ -790,6 +799,8 @@ impl MedalConnection for Connection {
public: row.get(9), public: row.get(9),
start: row.get(10), start: row.get(10),
end: row.get(11), end: row.get(11),
min_grade: row.get(12),
max_grade: row.get(13),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
}) })
.unwrap() .unwrap()
...@@ -1000,8 +1011,9 @@ impl MedalObject<Connection> for Contest { ...@@ -1000,8 +1011,9 @@ impl MedalObject<Connection> for Contest {
let id = match self.get_id() { let id = match self.get_id() {
Some(id) => { Some(id) => {
let query = "UPDATE contest let query = "UPDATE contest
SET location = $1,filename = $2, name = $3, duration = $4, public = $5, start_date = $6, end_date = $7 SET location = $1,filename = $2, name = $3, duration = $4, public = $5, start_date = $6,
WHERE id = $8"; end_date = $7, min_grade =$8 , max_grade = $9
WHERE id = $10";
conn.execute(query, conn.execute(query,
&[&self.location, &[&self.location,
&self.filename, &self.filename,
...@@ -1010,13 +1022,16 @@ impl MedalObject<Connection> for Contest { ...@@ -1010,13 +1022,16 @@ impl MedalObject<Connection> for Contest {
&self.public, &self.public,
&self.start, &self.start,
&self.end, &self.end,
&self.min_grade,
&self.max_grade,
&id]) &id])
.unwrap(); .unwrap();
id id
} }
None => { None => {
let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date) let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date,
VALUES ($1, $2, $3, $4, $5, $6, $7)"; min_grade, max_grade)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)";
conn.execute(query, conn.execute(query,
&[&self.location, &[&self.location,
&self.filename, &self.filename,
...@@ -1024,7 +1039,9 @@ impl MedalObject<Connection> for Contest { ...@@ -1024,7 +1039,9 @@ impl MedalObject<Connection> for Contest {
&self.duration, &self.duration,
&self.public, &self.public,
&self.start, &self.start,
&self.end]) &self.end,
&self.min_grade,
&self.max_grade])
.unwrap(); .unwrap();
conn.get_last_id().unwrap() conn.get_last_id().unwrap()
} }
......
...@@ -614,7 +614,7 @@ impl MedalConnection for Connection { ...@@ -614,7 +614,7 @@ impl MedalConnection for Connection {
} }
fn get_contest_list(&self) -> Vec<Contest> { fn get_contest_list(&self) -> Vec<Contest> {
let query = "SELECT id, location, filename, name, duration, public, start_date, end_date let query = "SELECT id, location, filename, name, duration, public, start_date, end_date, min_grade, max_grade
FROM contest FROM contest
ORDER BY id"; ORDER BY id";
self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)), self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)),
...@@ -625,12 +625,14 @@ impl MedalConnection for Connection { ...@@ -625,12 +625,14 @@ impl MedalConnection for Connection {
public: row.get(5), public: row.get(5),
start: row.get(6), start: row.get(6),
end: row.get(7), end: row.get(7),
min_grade: row.get(8),
max_grade: row.get(9),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
.unwrap() .unwrap()
} }
fn get_contest_by_id(&self, contest_id: i32) -> Contest { fn get_contest_by_id(&self, contest_id: i32) -> Contest {
let query = "SELECT location, filename, name, duration, public, start_date, end_date let query = "SELECT location, filename, name, duration, public, start_date, end_date, min_grade, max_grade
FROM contest FROM contest
WHERE id = ?1"; WHERE id = ?1";
self.query_map_one(query, &[&contest_id], |row| Contest { id: Some(contest_id), self.query_map_one(query, &[&contest_id], |row| Contest { id: Some(contest_id),
...@@ -641,6 +643,8 @@ impl MedalConnection for Connection { ...@@ -641,6 +643,8 @@ impl MedalConnection for Connection {
public: row.get(4), public: row.get(4),
start: row.get(5), start: row.get(5),
end: row.get(6), end: row.get(6),
min_grade: row.get(7),
max_grade: row.get(8),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
.unwrap() .unwrap()
.unwrap() // TODO: Should return Option? .unwrap() // TODO: Should return Option?
...@@ -648,8 +652,8 @@ impl MedalConnection for Connection { ...@@ -648,8 +652,8 @@ impl MedalConnection for Connection {
fn get_contest_by_id_complete(&self, contest_id: i32) -> Contest { fn get_contest_by_id_complete(&self, contest_id: i32) -> Contest {
let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public, let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public,
contest.start_date, contest.end_date, taskgroup.id, taskgroup.name, task.id, task.location, contest.start_date, contest.end_date, contest.min_grade, contest.max_grade, taskgroup.id,
task.stars taskgroup.name, task.id, task.location, task.stars
FROM contest FROM contest
JOIN taskgroup ON contest.id = taskgroup.contest JOIN taskgroup ON contest.id = taskgroup.contest
JOIN task ON taskgroup.id = task.taskgroup JOIN task ON taskgroup.id = task.taskgroup
...@@ -665,13 +669,15 @@ impl MedalConnection for Connection { ...@@ -665,13 +669,15 @@ impl MedalConnection for Connection {
public: row.get(4), public: row.get(4),
start: row.get(5), start: row.get(5),
end: row.get(6), end: row.get(6),
min_grade: row.get(7),
max_grade: row.get(8),
taskgroups: Vec::new() }, taskgroups: Vec::new() },
Taskgroup { id: Some(row.get(7)), Taskgroup { id: Some(row.get(9)),
contest: contest_id, contest: contest_id,
name: row.get(8), name: row.get(10),
positionalnumber: None, positionalnumber: None,
tasks: Vec::new() }, tasks: Vec::new() },
Task { id: Some(row.get(9)), taskgroup: row.get(7), location: row.get(10), stars: row.get(11) }) Task { id: Some(row.get(11)), taskgroup: row.get(9), location: row.get(12), stars: row.get(13) })
}) })
.unwrap(); .unwrap();
let mut taskgroupcontest_iter = taskgroupcontest.into_iter(); let mut taskgroupcontest_iter = taskgroupcontest.into_iter();
...@@ -692,7 +698,8 @@ impl MedalConnection for Connection { ...@@ -692,7 +698,8 @@ impl MedalConnection for Connection {
fn get_contest_by_id_partial(&self, contest_id: i32) -> Contest { fn get_contest_by_id_partial(&self, contest_id: i32) -> Contest {
let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public, let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public,
contest.start_date, contest.end_date, taskgroup.id, taskgroup.name contest.start_date, contest.end_date, contest.min_grade, contest.max_grade, taskgroup.id,
taskgroup.name
FROM contest FROM contest
JOIN taskgroup ON contest.id = taskgroup.contest JOIN taskgroup ON contest.id = taskgroup.contest
WHERE contest.id = ?1"; WHERE contest.id = ?1";
...@@ -705,10 +712,12 @@ impl MedalConnection for Connection { ...@@ -705,10 +712,12 @@ impl MedalConnection for Connection {
public: row.get(4), public: row.get(4),
start: row.get(5), start: row.get(5),
end: row.get(6), end: row.get(6),
min_grade: row.get(7),
max_grade: row.get(8),
taskgroups: Vec::new() }, taskgroups: Vec::new() },
Taskgroup { id: Some(row.get(7)), Taskgroup { id: Some(row.get(9)),
contest: contest_id, contest: contest_id,
name: row.get(8), name: row.get(10),
positionalnumber: None, positionalnumber: None,
tasks: Vec::new() }) tasks: Vec::new() })
}) })
...@@ -770,7 +779,7 @@ impl MedalConnection for Connection { ...@@ -770,7 +779,7 @@ impl MedalConnection for Connection {
fn get_task_by_id_complete(&self, task_id: i32) -> (Task, Taskgroup, Contest) { fn get_task_by_id_complete(&self, task_id: i32) -> (Task, Taskgroup, Contest) {
let query = "SELECT task.location, task.stars, taskgroup.id, taskgroup.name, contest.id, contest.location, let query = "SELECT task.location, task.stars, taskgroup.id, taskgroup.name, contest.id, contest.location,
contest.filename, contest.name, contest.duration, contest.public, contest.start_date, contest.filename, contest.name, contest.duration, contest.public, contest.start_date,
contest.end_date contest.end_date, contest.min_grade, contest.max_grade
FROM contest FROM contest
JOIN taskgroup ON taskgroup.contest = contest.id JOIN taskgroup ON taskgroup.contest = contest.id
JOIN task ON task.taskgroup = taskgroup.id JOIN task ON task.taskgroup = taskgroup.id
...@@ -790,6 +799,8 @@ impl MedalConnection for Connection { ...@@ -790,6 +799,8 @@ impl MedalConnection for Connection {
public: row.get(9), public: row.get(9),
start: row.get(10), start: row.get(10),
end: row.get(11), end: row.get(11),
min_grade: row.get(12),
max_grade: row.get(13),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
}) })
.unwrap() .unwrap()
...@@ -1000,8 +1011,9 @@ impl MedalObject<Connection> for Contest { ...@@ -1000,8 +1011,9 @@ impl MedalObject<Connection> for Contest {
let id = match self.get_id() { let id = match self.get_id() {
Some(id) => { Some(id) => {
let query = "UPDATE contest let query = "UPDATE contest
SET location = ?1,filename = ?2, name = ?3, duration = ?4, public = ?5, start_date = ?6, end_date = ?7 SET location = ?1, filename = ?2, name = ?3, duration = ?4, public = ?5, start_date = ?6,
WHERE id = ?8"; end_date = ?7, min_grade = ?8, max_grade =?9
WHERE id = ?10";
conn.execute(query, conn.execute(query,
&[&self.location, &[&self.location,
&self.filename, &self.filename,
...@@ -1010,13 +1022,16 @@ impl MedalObject<Connection> for Contest { ...@@ -1010,13 +1022,16 @@ impl MedalObject<Connection> for Contest {
&self.public, &self.public,
&self.start, &self.start,
&self.end, &self.end,
&self.min_grade,
&self.max_grade,
&id]) &id])
.unwrap(); .unwrap();
id id
} }
None => { None => {
let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date) let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date,
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)"; min_grade, max_grade)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)";
conn.execute(query, conn.execute(query,
&[&self.location, &[&self.location,
&self.filename, &self.filename,
...@@ -1024,7 +1039,9 @@ impl MedalObject<Connection> for Contest { ...@@ -1024,7 +1039,9 @@ impl MedalObject<Connection> for Contest {
&self.duration, &self.duration,
&self.public, &self.public,
&self.start, &self.start,
&self.end]) &self.end,
&self.min_grade,
&self.max_grade])
.unwrap(); .unwrap();
conn.get_last_id().unwrap() conn.get_last_id().unwrap()
} }
......
...@@ -614,7 +614,7 @@ impl MedalConnection for Connection { ...@@ -614,7 +614,7 @@ impl MedalConnection for Connection {
} }
fn get_contest_list(&self) -> Vec<Contest> { fn get_contest_list(&self) -> Vec<Contest> {
let query = "SELECT id, location, filename, name, duration, public, start_date, end_date let query = "SELECT id, location, filename, name, duration, public, start_date, end_date, min_grade, max_grade
FROM contest FROM contest
ORDER BY id"; ORDER BY id";
self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)), self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)),
...@@ -625,12 +625,14 @@ impl MedalConnection for Connection { ...@@ -625,12 +625,14 @@ impl MedalConnection for Connection {
public: row.get(5), public: row.get(5),
start: row.get(6), start: row.get(6),
end: row.get(7), end: row.get(7),
min_grade: row.get(8),
max_grade: row.get(9),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
.unwrap() .unwrap()
} }
fn get_contest_by_id(&self, contest_id: i32) -> Contest { fn get_contest_by_id(&self, contest_id: i32) -> Contest {
let query = "SELECT location, filename, name, duration, public, start_date, end_date let query = "SELECT location, filename, name, duration, public, start_date, end_date, min_grade, max_grade
FROM contest FROM contest
WHERE id = ?1"; WHERE id = ?1";
self.query_map_one(query, &[&contest_id], |row| Contest { id: Some(contest_id), self.query_map_one(query, &[&contest_id], |row| Contest { id: Some(contest_id),
...@@ -641,6 +643,8 @@ impl MedalConnection for Connection { ...@@ -641,6 +643,8 @@ impl MedalConnection for Connection {
public: row.get(4), public: row.get(4),
start: row.get(5), start: row.get(5),
end: row.get(6), end: row.get(6),
min_grade: row.get(7),
max_grade: row.get(8),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
.unwrap() .unwrap()
.unwrap() // TODO: Should return Option? .unwrap() // TODO: Should return Option?
...@@ -648,8 +652,8 @@ impl MedalConnection for Connection { ...@@ -648,8 +652,8 @@ impl MedalConnection for Connection {
fn get_contest_by_id_complete(&self, contest_id: i32) -> Contest { fn get_contest_by_id_complete(&self, contest_id: i32) -> Contest {
let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public, let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public,
contest.start_date, contest.end_date, taskgroup.id, taskgroup.name, task.id, task.location, contest.start_date, contest.end_date, contest.min_grade, contest.max_grade, taskgroup.id,
task.stars taskgroup.name, task.id, task.location, task.stars
FROM contest FROM contest
JOIN taskgroup ON contest.id = taskgroup.contest JOIN taskgroup ON contest.id = taskgroup.contest
JOIN task ON taskgroup.id = task.taskgroup JOIN task ON taskgroup.id = task.taskgroup
...@@ -665,13 +669,15 @@ impl MedalConnection for Connection { ...@@ -665,13 +669,15 @@ impl MedalConnection for Connection {
public: row.get(4), public: row.get(4),
start: row.get(5), start: row.get(5),
end: row.get(6), end: row.get(6),
min_grade: row.get(7),
max_grade: row.get(8),
taskgroups: Vec::new() }, taskgroups: Vec::new() },
Taskgroup { id: Some(row.get(7)), Taskgroup { id: Some(row.get(9)),
contest: contest_id, contest: contest_id,
name: row.get(8), name: row.get(10),
positionalnumber: None, positionalnumber: None,
tasks: Vec::new() }, tasks: Vec::new() },
Task { id: Some(row.get(9)), taskgroup: row.get(7), location: row.get(10), stars: row.get(11) }) Task { id: Some(row.get(11)), taskgroup: row.get(9), location: row.get(12), stars: row.get(13) })
}) })
.unwrap(); .unwrap();
let mut taskgroupcontest_iter = taskgroupcontest.into_iter(); let mut taskgroupcontest_iter = taskgroupcontest.into_iter();
...@@ -692,7 +698,8 @@ impl MedalConnection for Connection { ...@@ -692,7 +698,8 @@ impl MedalConnection for Connection {
fn get_contest_by_id_partial(&self, contest_id: i32) -> Contest { fn get_contest_by_id_partial(&self, contest_id: i32) -> Contest {
let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public, let query = "SELECT contest.location, contest.filename, contest.name, contest.duration, contest.public,
contest.start_date, contest.end_date, taskgroup.id, taskgroup.name contest.start_date, contest.end_date, contest.min_grade, contest.max_grade, taskgroup.id,
taskgroup.name
FROM contest FROM contest
JOIN taskgroup ON contest.id = taskgroup.contest JOIN taskgroup ON contest.id = taskgroup.contest
WHERE contest.id = ?1"; WHERE contest.id = ?1";
...@@ -705,10 +712,12 @@ impl MedalConnection for Connection { ...@@ -705,10 +712,12 @@ impl MedalConnection for Connection {
public: row.get(4), public: row.get(4),
start: row.get(5), start: row.get(5),
end: row.get(6), end: row.get(6),
min_grade: row.get(7),
max_grade: row.get(8),
taskgroups: Vec::new() }, taskgroups: Vec::new() },
Taskgroup { id: Some(row.get(7)), Taskgroup { id: Some(row.get(9)),
contest: contest_id, contest: contest_id,
name: row.get(8), name: row.get(10),
positionalnumber: None, positionalnumber: None,
tasks: Vec::new() }) tasks: Vec::new() })
}) })
...@@ -770,7 +779,7 @@ impl MedalConnection for Connection { ...@@ -770,7 +779,7 @@ impl MedalConnection for Connection {
fn get_task_by_id_complete(&self, task_id: i32) -> (Task, Taskgroup, Contest) { fn get_task_by_id_complete(&self, task_id: i32) -> (Task, Taskgroup, Contest) {
let query = "SELECT task.location, task.stars, taskgroup.id, taskgroup.name, contest.id, contest.location, let query = "SELECT task.location, task.stars, taskgroup.id, taskgroup.name, contest.id, contest.location,
contest.filename, contest.name, contest.duration, contest.public, contest.start_date, contest.filename, contest.name, contest.duration, contest.public, contest.start_date,
contest.end_date contest.end_date, contest.min_grade, contest.max_grade
FROM contest FROM contest
JOIN taskgroup ON taskgroup.contest = contest.id JOIN taskgroup ON taskgroup.contest = contest.id
JOIN task ON task.taskgroup = taskgroup.id JOIN task ON task.taskgroup = taskgroup.id
...@@ -790,6 +799,8 @@ impl MedalConnection for Connection { ...@@ -790,6 +799,8 @@ impl MedalConnection for Connection {
public: row.get(9), public: row.get(9),
start: row.get(10), start: row.get(10),
end: row.get(11),