Commit 1e820d3a authored by Robert Czechowski's avatar Robert Czechowski
Browse files

remove some unused functions, unused muts, unused vars

parent 0b3260ca
......@@ -10,7 +10,7 @@ use rand::{thread_rng, Rng, distributions::Alphanumeric};
use time;
use self::time::{Timespec, Duration};
use self::time::Duration;
use std::path::{Path};
......@@ -365,7 +365,7 @@ impl MedalConnection for Connection {
fn get_contest_groups_grades(&self, session_id: u32, contest_id: u32) -> (Vec<String>, Vec<(Group, Vec<(UserInfo, Vec<Grade>)>)>) {
let mut stmt = self.prepare("SELECT id, name FROM taskgroup WHERE contest = ?1 ORDER BY id ASC").unwrap();
let mut tasknames_iter = stmt.query_map(&[&contest_id], |row| {
let tasknames_iter = stmt.query_map(&[&contest_id], |row| {
let x : (u32, String) = (row.get(0), row.get(1));
x
}).unwrap();
......@@ -452,7 +452,7 @@ impl MedalConnection for Connection {
}
fn get_contest_user_grades(&self, session_token: String, contest_id: u32) -> Vec<Grade> {
let mut stmt = self.prepare("SELECT id, name FROM taskgroup WHERE contest = ?1 ORDER BY id ASC").unwrap();
let mut tasknames_iter = stmt.query_map(&[&contest_id], |row| {
let tasknames_iter = stmt.query_map(&[&contest_id], |row| {
let x : (u32, String) = (row.get(0), row.get(1));
x
}).unwrap();
......@@ -473,7 +473,7 @@ impl MedalConnection for Connection {
JOIN session_user ON session_user.id = grade.user
WHERE session_user.session_token = ?1 AND taskgroup.contest = ?2
ORDER BY taskgroup.id ASC").unwrap();
let mut gradeinfo_iter = stmt.query_map(&[&session_token, &contest_id], |row| {
let gradeinfo_iter = stmt.query_map(&[&session_token, &contest_id], |row| {
Grade {
taskgroup: row.get(0),
user: row.get(1),
......@@ -583,7 +583,7 @@ impl MedalConnection for Connection {
}).ok()
}
fn new_participation(&self, session: &str, contest_id: u32) -> Result<Participation, ()> {
match self.query_row("SELECT user, start_date FROM participation JOIN session_user ON session_user.id = user WHERE session_user.session_token = ?1 AND contest = ?2", &[&session, &contest_id], |row| {()}) {
match self.query_row("SELECT user, start_date FROM participation JOIN session_user ON session_user.id = user WHERE session_user.session_token = ?1 AND contest = ?2", &[&session, &contest_id], |_| {()}) {
Ok(()) => Err(()),
Err(_) => {
let now = time::get_time();
......@@ -673,7 +673,7 @@ impl MedalConnection for Connection {
}).unwrap().filter_map(|row| {row.ok()}).collect();
rows
}
fn get_groups_complete(&self, session_id: u32) -> Vec<Group> {unimplemented!();}
fn get_groups_complete(&self, _session_id: u32) -> Vec<Group> {unimplemented!();}
fn get_group_complete(&self, group_id: u32) -> Option<Group> {
let mut group = self.query_row("SELECT name, groupcode, tag, admin FROM usergroup WHERE id = ?1", &[&group_id], |row| {
Group {
......
......@@ -12,41 +12,6 @@ use db_objects::{Submission, Group, SessionUser};
use self::bcrypt::{DEFAULT_COST, hash, verify, BcryptError};
pub fn blaa() -> (String, json_val::Map<String, json_val::Value>) {
let mut data = json_val::Map::new();
let mut contests = Vec::new();
contests.push("blaa".to_string());
data.insert("contest".to_string(), to_json(&contests));
("greeting".to_owned(), data)
}
pub fn index<T: MedalConnection>(conn: &T, session_token: Option<String>, (self_url, oauth_url): (Option<String>, Option<String>)) -> (String, json_val::Map<String, json_val::Value>) {
let mut data = json_val::Map::new();
//let mut contests = Vec::new();
if let Some(token) = session_token {
if let Some(session) = conn.get_session(&token) {
data.insert("logged_in".to_string(), to_json(&true));
data.insert("username".to_string(), to_json(&session.username));
data.insert("firstname".to_string(), to_json(&session.firstname));
data.insert("lastname".to_string(), to_json(&session.lastname));
data.insert("teacher".to_string(), to_json(&session.is_teacher));
}
}
data.insert("self_url".to_string(), to_json(&self_url));
data.insert("oauth_url".to_string(), to_json(&oauth_url));
/*contests.push("blaa".to_string());
data.insert("contest".to_string(), to_json(&contests));*/
("index".to_owned(), data)
}
#[derive(Serialize, Deserialize)]
pub struct SubTaskInfo {
pub id: u32,
......@@ -93,6 +58,31 @@ type MedalResult<T> = Result<T, MedalError>;
type MedalValueResult = MedalResult<MedalValue>;
pub fn index<T: MedalConnection>(conn: &T, session_token: Option<String>, (self_url, oauth_url): (Option<String>, Option<String>)) -> (String, json_val::Map<String, json_val::Value>) {
let mut data = json_val::Map::new();
//let mut contests = Vec::new();
if let Some(token) = session_token {
if let Some(session) = conn.get_session(&token) {
data.insert("logged_in".to_string(), to_json(&true));
data.insert("username".to_string(), to_json(&session.username));
data.insert("firstname".to_string(), to_json(&session.firstname));
data.insert("lastname".to_string(), to_json(&session.lastname));
data.insert("teacher".to_string(), to_json(&session.is_teacher));
}
}
data.insert("self_url".to_string(), to_json(&self_url));
data.insert("oauth_url".to_string(), to_json(&oauth_url));
/*contests.push("blaa".to_string());
data.insert("contest".to_string(), to_json(&contests));*/
("index".to_owned(), data)
}
pub fn show_contests<T: MedalConnection>(conn: &T) -> MedalValue {
let mut data = json_val::Map::new();
......@@ -459,7 +449,7 @@ pub fn show_groups_results<T: MedalConnection>(conn: &T, contest_id: u32, sessio
let session = conn.get_session_or_new(&session_token).ensure_logged_in().ok_or(MedalError::NotLoggedIn)?;
let g = conn.get_contest_groups_grades(session.id, contest_id);
let mut data = json_val::Map::new();
let data = json_val::Map::new();
Ok(("groupresults".into(), data))
}
......
......@@ -7,9 +7,7 @@ extern crate router;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate structopt;
extern crate rusqlite;
extern crate iron_sessionstorage;
extern crate urlencoded;
......@@ -226,7 +224,10 @@ fn main() {
println!("");
}
start_server(conn, config);
match start_server(conn, config) {
Ok(_) => println!("Ok"),
Err(_) => println!("Err")
};
println!("Could not run server. Is the port already in use?");
}
......
......@@ -31,9 +31,6 @@ pub use serde_json::value as json_val;
use iron::typemap::Key;
static DB_FILE: &'static str = "medal.db";
static TASK_DIR: &'static str = "tasks";
macro_rules! mime {
......@@ -222,10 +219,6 @@ impl<'c, 'a, 'b> From<AugMedalError<'c, 'a, 'b>> for IronError {
}
}
fn m_add<'c, 'a: 'c, 'b: 'c + 'a>(req: &'c mut Request<'a, 'b>) -> impl FnOnce(functions::MedalError) -> AugMedalError<'c, 'a, 'b> {
move |t : functions::MedalError| {AugMedalError(t.clone(), req)}
}
trait RequestAugmentMedalError<'c, 'a: 'c, 'b: 'c + 'a, R> {
fn aug(self, req: &'c mut Request<'a, 'b>) -> Result<R, AugMedalError<'c, 'a, 'b>>;
......@@ -237,6 +230,7 @@ impl<'c, 'a: 'c, 'b: 'c + 'a, T> RequestAugmentMedalError<'c, 'a, 'b, T> for Res
}
<<<<<<< HEAD
fn greet(_req: &mut Request) -> IronResult<Response> {
// hier ggf. Daten aus dem Request holen
......@@ -249,6 +243,8 @@ fn greet(_req: &mut Request) -> IronResult<Response> {
Ok(resp)
}
=======
>>>>>>> remove some unused functions, unused muts, unused vars
fn greet_personal(req: &mut Request) -> IronResult<Response> {
let session_token = req.get_session_token();
// hier ggf. Daten aus dem Request holen
......
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