Commit 9ba792fa authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Add database columns 'requires_login' and 'secret' to contest

parent 4e5c9c13
Pipeline #545 passed with stage
in 8 minutes and 38 seconds
ALTER TABLE contest ADD COLUMN requires_login BOOL;
ALTER TABLE contest ADD COLUMN secret TEXT;
ALTER TABLE contest ADD COLUMN requires_login INTEGER;
ALTER TABLE contest ADD COLUMN secret TEXT;
...@@ -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>,
requires_login: Option<bool>,
secret: Option<String>,
min_grade: Option<i32>, min_grade: Option<i32>,
max_grade: Option<i32>, max_grade: Option<i32>,
position: Option<i32>, position: Option<i32>,
...@@ -42,7 +45,9 @@ pub fn parse_yaml(content: &str, filename: &str, directory: &str) -> Option<Cont ...@@ -42,7 +45,9 @@ pub fn parse_yaml(content: &str, filename: &str, directory: &str) -> Option<Cont
}), }),
config.min_grade, config.min_grade,
config.max_grade, config.max_grade,
config.position); config.position,
config.requires_login,
config.secret);
// 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() {
......
...@@ -111,11 +111,13 @@ impl MedalObject<Connection> for Contest { ...@@ -111,11 +111,13 @@ 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, SET location = $2,filename = $3, name = $4, duration = $5, public = $6, start_date = $7,
end_date = $7, min_grade = $8, max_grade = $9, positionalnumber = $10 end_date = $8, min_grade = $9, max_grade = $10, positionalnumber = $11,
WHERE id = $11"; requires_login = $12, secret = $13
WHERE id = $1";
conn.execute(query, conn.execute(query,
&[&self.location, &[&id,
&self.location,
&self.filename, &self.filename,
&self.name, &self.name,
&self.duration, &self.duration,
...@@ -125,14 +127,15 @@ impl MedalObject<Connection> for Contest { ...@@ -125,14 +127,15 @@ impl MedalObject<Connection> for Contest {
&self.min_grade, &self.min_grade,
&self.max_grade, &self.max_grade,
&self.positionalnumber, &self.positionalnumber,
&id]) &self.requires_login,
&self.secret])
.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,
min_grade, max_grade, positionalnumber) min_grade, max_grade, positionalnumber, requires_login, secret)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)"; VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)";
conn.execute(query, conn.execute(query,
&[&self.location, &[&self.location,
&self.filename, &self.filename,
...@@ -143,7 +146,9 @@ impl MedalObject<Connection> for Contest { ...@@ -143,7 +146,9 @@ impl MedalObject<Connection> for Contest {
&self.end, &self.end,
&self.min_grade, &self.min_grade,
&self.max_grade, &self.max_grade,
&self.positionalnumber]) &self.positionalnumber,
&self.requires_login,
&self.secret])
.unwrap(); .unwrap();
conn.get_last_id().unwrap() conn.get_last_id().unwrap()
} }
...@@ -750,7 +755,7 @@ impl MedalConnection for Connection { ...@@ -750,7 +755,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, min_grade, max_grade, let query = "SELECT id, location, filename, name, duration, public, start_date, end_date, min_grade, max_grade,
positionalnumber positionalnumber, requires_login, secret
FROM contest FROM contest
ORDER BY positionalnumber"; ORDER BY positionalnumber";
self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)), self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)),
...@@ -764,12 +769,15 @@ impl MedalConnection for Connection { ...@@ -764,12 +769,15 @@ impl MedalConnection for Connection {
min_grade: row.get(8), min_grade: row.get(8),
max_grade: row.get(9), max_grade: row.get(9),
positionalnumber: row.get(10), positionalnumber: row.get(10),
requires_login: row.get(11),
secret: row.get(12),
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, min_grade, max_grade let query = "SELECT location, filename, name, duration, public, start_date, end_date, min_grade, max_grade,
requires_login, secret
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),
...@@ -783,6 +791,8 @@ impl MedalConnection for Connection { ...@@ -783,6 +791,8 @@ impl MedalConnection for Connection {
min_grade: row.get(7), min_grade: row.get(7),
max_grade: row.get(8), max_grade: row.get(8),
positionalnumber: None, positionalnumber: None,
requires_login: row.get(9),
secret: row.get(10),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
.unwrap() .unwrap()
.unwrap() // TODO: Should return Option? .unwrap() // TODO: Should return Option?
...@@ -790,8 +800,9 @@ impl MedalConnection for Connection { ...@@ -790,8 +800,9 @@ 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, contest.min_grade, contest.max_grade, taskgroup.id, contest.start_date, contest.end_date, contest.min_grade, contest.max_grade,
taskgroup.name, task.id, task.location, task.stars contest.requires_login, contest.secret, taskgroup.id, 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
...@@ -811,14 +822,16 @@ impl MedalConnection for Connection { ...@@ -811,14 +822,16 @@ impl MedalConnection for Connection {
min_grade: row.get(7), min_grade: row.get(7),
max_grade: row.get(8), max_grade: row.get(8),
positionalnumber: None, positionalnumber: None,
requires_login: row.get(9),
secret: row.get(10),
taskgroups: Vec::new() }, taskgroups: Vec::new() },
Taskgroup { id: Some(row.get(9)), Taskgroup { id: Some(row.get(11)),
contest: contest_id, contest: contest_id,
name: row.get(10), name: row.get(12),
active: true, active: true,
positionalnumber: None, positionalnumber: None,
tasks: Vec::new() }, tasks: Vec::new() },
Task { id: Some(row.get(11)), taskgroup: row.get(9), location: row.get(12), stars: row.get(13) }) Task { id: Some(row.get(13)), taskgroup: row.get(11), location: row.get(14), stars: row.get(15) })
}) })
.unwrap(); .unwrap();
let mut taskgroupcontest_iter = taskgroupcontest.into_iter(); let mut taskgroupcontest_iter = taskgroupcontest.into_iter();
...@@ -839,8 +852,8 @@ impl MedalConnection for Connection { ...@@ -839,8 +852,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, contest.min_grade, contest.max_grade, taskgroup.id, contest.start_date, contest.end_date, contest.min_grade, contest.max_grade,
taskgroup.name contest.requires_login, contest_secret, 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
...@@ -857,10 +870,12 @@ impl MedalConnection for Connection { ...@@ -857,10 +870,12 @@ impl MedalConnection for Connection {
min_grade: row.get(7), min_grade: row.get(7),
max_grade: row.get(8), max_grade: row.get(8),
positionalnumber: None, positionalnumber: None,
requires_login: row.get(9),
secret: row.get(10),
taskgroups: Vec::new() }, taskgroups: Vec::new() },
Taskgroup { id: Some(row.get(9)), Taskgroup { id: Some(row.get(11)),
contest: contest_id, contest: contest_id,
name: row.get(10), name: row.get(12),
active: true, active: true,
positionalnumber: None, positionalnumber: None,
tasks: Vec::new() }) tasks: Vec::new() })
...@@ -923,7 +938,8 @@ impl MedalConnection for Connection { ...@@ -923,7 +938,8 @@ 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, taskgroup.active, contest.id, let query = "SELECT task.location, task.stars, taskgroup.id, taskgroup.name, taskgroup.active, contest.id,
contest.location, contest.filename, contest.name, contest.duration, contest.public, contest.location, contest.filename, contest.name, contest.duration, contest.public,
contest.start_date, contest.end_date, contest.min_grade, contest.max_grade contest.start_date, contest.end_date, contest.min_grade, contest.max_grade,
contest.requires_login, contest.secret
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
...@@ -947,6 +963,8 @@ impl MedalConnection for Connection { ...@@ -947,6 +963,8 @@ impl MedalConnection for Connection {
min_grade: row.get(13), min_grade: row.get(13),
max_grade: row.get(14), max_grade: row.get(14),
positionalnumber: None, positionalnumber: None,
requires_login: row.get(15),
secret: row.get(16),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
}) })
.unwrap() .unwrap()
......
...@@ -207,11 +207,13 @@ impl MedalObject<Connection> for Contest { ...@@ -207,11 +207,13 @@ 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, SET location = $2,filename = $3, name = $4, duration = $5, public = $6, start_date = $7,
end_date = $7, min_grade = $8, max_grade = $9, positionalnumber = $10 end_date = $8, min_grade = $9, max_grade = $10, positionalnumber = $11,
WHERE id = $11"; requires_login = $12, secret = $13
WHERE id = $1";
conn.execute(query, conn.execute(query,
&[&self.location, &[&id,
&self.location,
&self.filename, &self.filename,
&self.name, &self.name,
&self.duration, &self.duration,
...@@ -221,14 +223,15 @@ impl MedalObject<Connection> for Contest { ...@@ -221,14 +223,15 @@ impl MedalObject<Connection> for Contest {
&self.min_grade, &self.min_grade,
&self.max_grade, &self.max_grade,
&self.positionalnumber, &self.positionalnumber,
&id]) &self.requires_login,
&self.secret])
.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,
min_grade, max_grade, positionalnumber) min_grade, max_grade, positionalnumber, requires_login, secret)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)"; VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)";
conn.execute(query, conn.execute(query,
&[&self.location, &[&self.location,
&self.filename, &self.filename,
...@@ -239,7 +242,9 @@ impl MedalObject<Connection> for Contest { ...@@ -239,7 +242,9 @@ impl MedalObject<Connection> for Contest {
&self.end, &self.end,
&self.min_grade, &self.min_grade,
&self.max_grade, &self.max_grade,
&self.positionalnumber]) &self.positionalnumber,
&self.requires_login,
&self.secret])
.unwrap(); .unwrap();
conn.get_last_id().unwrap() conn.get_last_id().unwrap()
} }
...@@ -846,7 +851,7 @@ impl MedalConnection for Connection { ...@@ -846,7 +851,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, min_grade, max_grade, let query = "SELECT id, location, filename, name, duration, public, start_date, end_date, min_grade, max_grade,
positionalnumber positionalnumber, requires_login, secret
FROM contest FROM contest
ORDER BY positionalnumber"; ORDER BY positionalnumber";
self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)), self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)),
...@@ -860,12 +865,15 @@ impl MedalConnection for Connection { ...@@ -860,12 +865,15 @@ impl MedalConnection for Connection {
min_grade: row.get(8), min_grade: row.get(8),
max_grade: row.get(9), max_grade: row.get(9),
positionalnumber: row.get(10), positionalnumber: row.get(10),
requires_login: row.get(11),
secret: row.get(12),
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, min_grade, max_grade let query = "SELECT location, filename, name, duration, public, start_date, end_date, min_grade, max_grade,
requires_login, secret
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),
...@@ -879,6 +887,8 @@ impl MedalConnection for Connection { ...@@ -879,6 +887,8 @@ impl MedalConnection for Connection {
min_grade: row.get(7), min_grade: row.get(7),
max_grade: row.get(8), max_grade: row.get(8),
positionalnumber: None, positionalnumber: None,
requires_login: row.get(9),
secret: row.get(10),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
.unwrap() .unwrap()
.unwrap() // TODO: Should return Option? .unwrap() // TODO: Should return Option?
...@@ -886,8 +896,9 @@ impl MedalConnection for Connection { ...@@ -886,8 +896,9 @@ 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, contest.min_grade, contest.max_grade, taskgroup.id, contest.start_date, contest.end_date, contest.min_grade, contest.max_grade,
taskgroup.name, task.id, task.location, task.stars contest.requires_login, contest.secret, taskgroup.id, 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
...@@ -907,14 +918,16 @@ impl MedalConnection for Connection { ...@@ -907,14 +918,16 @@ impl MedalConnection for Connection {
min_grade: row.get(7), min_grade: row.get(7),
max_grade: row.get(8), max_grade: row.get(8),
positionalnumber: None, positionalnumber: None,
requires_login: row.get(9),
secret: row.get(10),
taskgroups: Vec::new() }, taskgroups: Vec::new() },
Taskgroup { id: Some(row.get(9)), Taskgroup { id: Some(row.get(11)),
contest: contest_id, contest: contest_id,
name: row.get(10), name: row.get(12),
active: true, active: true,
positionalnumber: None, positionalnumber: None,
tasks: Vec::new() }, tasks: Vec::new() },
Task { id: Some(row.get(11)), taskgroup: row.get(9), location: row.get(12), stars: row.get(13) }) Task { id: Some(row.get(13)), taskgroup: row.get(11), location: row.get(14), stars: row.get(15) })
}) })
.unwrap(); .unwrap();
let mut taskgroupcontest_iter = taskgroupcontest.into_iter(); let mut taskgroupcontest_iter = taskgroupcontest.into_iter();
...@@ -935,8 +948,8 @@ impl MedalConnection for Connection { ...@@ -935,8 +948,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, contest.min_grade, contest.max_grade, taskgroup.id, contest.start_date, contest.end_date, contest.min_grade, contest.max_grade,
taskgroup.name contest.requires_login, contest_secret, 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
...@@ -953,10 +966,12 @@ impl MedalConnection for Connection { ...@@ -953,10 +966,12 @@ impl MedalConnection for Connection {
min_grade: row.get(7), min_grade: row.get(7),
max_grade: row.get(8), max_grade: row.get(8),
positionalnumber: None, positionalnumber: None,
requires_login: row.get(9),
secret: row.get(10),
taskgroups: Vec::new() }, taskgroups: Vec::new() },
Taskgroup { id: Some(row.get(9)), Taskgroup { id: Some(row.get(11)),
contest: contest_id, contest: contest_id,
name: row.get(10), name: row.get(12),
active: true, active: true,
positionalnumber: None, positionalnumber: None,
tasks: Vec::new() }) tasks: Vec::new() })
...@@ -1019,7 +1034,8 @@ impl MedalConnection for Connection { ...@@ -1019,7 +1034,8 @@ 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, taskgroup.active, contest.id, let query = "SELECT task.location, task.stars, taskgroup.id, taskgroup.name, taskgroup.active, contest.id,
contest.location, contest.filename, contest.name, contest.duration, contest.public, contest.location, contest.filename, contest.name, contest.duration, contest.public,
contest.start_date, contest.end_date, contest.min_grade, contest.max_grade contest.start_date, contest.end_date, contest.min_grade, contest.max_grade,
contest.requires_login, contest.secret
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
...@@ -1043,6 +1059,8 @@ impl MedalConnection for Connection { ...@@ -1043,6 +1059,8 @@ impl MedalConnection for Connection {
min_grade: row.get(13), min_grade: row.get(13),
max_grade: row.get(14), max_grade: row.get(14),
positionalnumber: None, positionalnumber: None,
requires_login: row.get(15),
secret: row.get(16),
taskgroups: Vec::new() }) taskgroups: Vec::new() })
}) })
.unwrap() .unwrap()
......
...@@ -207,11 +207,13 @@ impl MedalObject<Connection> for Contest { ...@@ -207,11 +207,13 @@ 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, SET location = ?2,filename = ?3, name = ?4, duration = ?5, public = ?6, start_date = ?7,
end_date = ?7, min_grade = ?8, max_grade = ?9, positionalnumber = ?10 end_date = ?8, min_grade = ?9, max_grade = ?10, positionalnumber = ?11,
WHERE id = ?11"; requires_login = ?12, secret = ?13
WHERE id = ?1";
conn.execute(query, conn.execute(query,
&[&self.location, &[&id,
&self.location,
&self.filename, &self.filename,
&self.name, &self.name,
&self.duration, &self.duration,
...@@ -221,14 +223,15 @@ impl MedalObject<Connection> for Contest { ...@@ -221,14 +223,15 @@ impl MedalObject<Connection> for Contest {
&self.min_grade, &self.min_grade,
&self.max_grade, &self.max_grade,
&self.positionalnumber, &self.positionalnumber,
&id]) &self.requires_login,
&self.secret])
.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,
min_grade, max_grade, positionalnumber) min_grade, max_grade, positionalnumber, requires_login, secret)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)"; VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)";
conn.execute(query, conn.execute(query,
&[&self.location, &[&self.location,
&self.filename, &self.filename,
...@@ -239,7 +242,9 @@ impl MedalObject<Connection> for Contest { ...@@ -239,7 +242,9 @@ impl MedalObject<Connection> for Contest {
&self.end, &self.end,
&self.min_grade, &self.min_grade,
&self.max_grade, &self.max_grade,
&self.positionalnumber]) &self.positionalnumber,
&self.requires_login,
&self.secret])
.unwrap(); .unwrap();
conn.get_last_id().unwrap() conn.get_last_id().unwrap()
} }
...@@ -846,7 +851,7 @@ impl MedalConnection for Connection { ...@@ -846,7 +851,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, min_grade, max_grade, let query = "SELECT id, location, filename, name, duration, public, start_date, end_date, min_grade, max_grade,
positionalnumber positionalnumber, requires_login, secret
FROM contest FROM contest
ORDER BY positionalnumber"; ORDER BY positionalnumber";
self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)), self.query_map_many(query, &[], |row| Contest { id: Some(row.get(0)),
...@@ -860,12 +865,15 @@ impl MedalConnection for Connection { ...@@ -860,12 +865,15 @@ impl MedalConnection for Connection {
min_grade: row.get(8), min_grade: row.get(8),
max_grade: row.get(9), max_grade: row.get(9),
positionalnumber: row.get(10), positionalnumber: row.get(10),
requires_login: row.get(11),
secret: row.get(12),
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, min_grade, max_grade let query = "SELECT location, filename, name, duration, public, start_date, end_date, min_grade, max_grade,
requires_login, secret
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),
...@@ -879,6 +887,8 @@ impl MedalConnection for Connection { ...@@ -879,6 +887,8 @@ impl MedalConnection for Connection {
min_grade: row.get(7), min_grade: row.get(7),
max_grade: row.get(8), max_grade: row.get(8),
positionalnumber: None, positionalnumber: None,
requires_login: row.get(9),
secret: row.get(10),
taskgroups: Vec::new() }) taskgr