Commit 0a028d6e authored by Robert Czechowski's avatar Robert Czechowski

Add basic information about database in debug page

parent 9e38e4d3
......@@ -114,12 +114,12 @@ pub fn debug<T: MedalConnection>(conn: &T, session_token: Option<String>)
}
}
data.insert("session".to_string(), to_json(&token));
println!("etwas session?!");
} else {
data.insert("session".to_string(), to_json(&"No session token given"));
println!("warum nix session?!");
}
data.insert("dbinfo".to_string(), to_json(&conn.get_debug_information()));
("debug".to_owned(), data)
}
......
......@@ -1033,5 +1033,50 @@ impl MedalConnection for Connection {
Some(group)
}
fn get_debug_information(&self) -> String {
let duration = Duration::minutes(60);
let now = time::get_time();
let then = now - duration;
let query = "SELECT count(*)
FROM session
WHERE last_activity > $1;";
let n_asession: i32 = self.query_map_one(query, &[&then], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM participation
WHERE start_date > $1;";
let n_apart: i32 = self.query_map_one(query, &[&then], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session;";
let n_session: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE oauth_foreign_id NOT NULL OR logincode NOT NULL;";
let n_user: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE oauth_foreign_id NOT NULL;";
let n_pmsuser: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE is_teacher = $1;";
let n_teacher: i32 = self.query_map_one(query, &[&true], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM participation;";
let n_part: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM submission;";
let n_sub: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
format!("{{Active Sessions: {}, Active Participations: {}, Session: {}, User: {}, PMS-User: {}, Teacher: {}, Participations: {}, Submissions: {}}}", n_asession, n_apart, n_session, n_user, n_pmsuser, n_teacher, n_part, n_sub)
}
fn reset_all_contest_visibilities(&self) { self.execute("UPDATE contest SET public = $1", &[&false]).unwrap(); }
}
......@@ -50,6 +50,8 @@ pub trait MedalConnection {
fn get_groups_complete(&self, session_id: i32) -> Vec<Group>;
fn get_group_complete(&self, group_id: i32) -> Option<Group>;
fn get_debug_information(&self) -> String;
fn reset_all_contest_visibilities(&self);
}
......
......@@ -1129,5 +1129,50 @@ impl MedalConnection for Connection {
Some(group)
}
fn get_debug_information(&self) -> String {
let duration = Duration::minutes(60);
let now = time::get_time();
let then = now - duration;
let query = "SELECT count(*)
FROM session
WHERE last_activity > $1;";
let n_asession: i32 = self.query_map_one(query, &[&then], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM participation
WHERE start_date > $1;";
let n_apart: i32 = self.query_map_one(query, &[&then], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session;";
let n_session: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE oauth_foreign_id NOT NULL OR logincode NOT NULL;";
let n_user: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE oauth_foreign_id NOT NULL;";
let n_pmsuser: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE is_teacher = $1;";
let n_teacher: i32 = self.query_map_one(query, &[&true], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM participation;";
let n_part: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM submission;";
let n_sub: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
format!("{{Active Sessions: {}, Active Participations: {}, Session: {}, User: {}, PMS-User: {}, Teacher: {}, Participations: {}, Submissions: {}}}", n_asession, n_apart, n_session, n_user, n_pmsuser, n_teacher, n_part, n_sub)
}
fn reset_all_contest_visibilities(&self) { self.execute("UPDATE contest SET public = $1", &[&false]).unwrap(); }
}
......@@ -1116,5 +1116,50 @@ impl MedalConnection for Connection {
Some(group)
}
fn get_debug_information(&self) -> String {
let duration = Duration::minutes(60);
let now = time::get_time();
let then = now - duration;
let query = "SELECT count(*)
FROM session
WHERE last_activity > ?1;";
let n_asession: i32 = self.query_map_one(query, &[&then], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM participation
WHERE start_date > ?1;";
let n_apart: i32 = self.query_map_one(query, &[&then], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session;";
let n_session: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE oauth_foreign_id NOT NULL OR logincode NOT NULL;";
let n_user: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE oauth_foreign_id NOT NULL;";
let n_pmsuser: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE is_teacher = ?1;";
let n_teacher: i32 = self.query_map_one(query, &[&true], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM participation;";
let n_part: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM submission;";
let n_sub: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
format!("{{Active Sessions: {}, Active Participations: {}, Session: {}, User: {}, PMS-User: {}, Teacher: {}, Participations: {}, Submissions: {}}}", n_asession, n_apart, n_session, n_user, n_pmsuser, n_teacher, n_part, n_sub)
}
fn reset_all_contest_visibilities(&self) { self.execute("UPDATE contest SET public = ?1", &[&false]).unwrap(); }
}
......@@ -1129,5 +1129,50 @@ impl MedalConnection for Connection {
Some(group)
}
fn get_debug_information(&self) -> String {
let duration = Duration::minutes(60);
let now = time::get_time();
let then = now - duration;
let query = "SELECT count(*)
FROM session
WHERE last_activity > ?1;";
let n_asession: i32 = self.query_map_one(query, &[&then], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM participation
WHERE start_date > ?1;";
let n_apart: i32 = self.query_map_one(query, &[&then], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session;";
let n_session: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE oauth_foreign_id NOT NULL OR logincode NOT NULL;";
let n_user: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE oauth_foreign_id NOT NULL;";
let n_pmsuser: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM session
WHERE is_teacher = ?1;";
let n_teacher: i32 = self.query_map_one(query, &[&true], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM participation;";
let n_part: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT count(*)
FROM submission;";
let n_sub: i32 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
format!("{{Active Sessions: {}, Active Participations: {}, Session: {}, User: {}, PMS-User: {}, Teacher: {}, Participations: {}, Submissions: {}}}", n_asession, n_apart, n_session, n_user, n_pmsuser, n_teacher, n_part, n_sub)
}
fn reset_all_contest_visibilities(&self) { self.execute("UPDATE contest SET public = ?1", &[&false]).unwrap(); }
}
......@@ -25,3 +25,5 @@
<p><a href="/debug/reset">Neues Token</a>
<p><a href="/debug/create">Erzeuge Session in DB</a>
<p>Datenbank: {{dbinfo}}
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