Commit 7e788cad authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Implement new query for participation statistics

parent 37d037c4
Pipeline #563 passed with stage
in 8 minutes and 39 seconds
......@@ -1128,22 +1128,26 @@ impl MedalConnection for Connection {
FROM participation
GROUP BY contest
ORDER BY contest DESC;";
let n_sub: i64 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let n_participations_by_id: Vec<(i64, i64)> = self.query_map_many(query, &[], |row| (row.get(0), row.get(1))).unwrap();
format!(
"{{
'timestamp': {},
'active_sessions': {},
'active_participations': {},
'sessions': {},
'users': {},
'pms_users': {},
'teachers': {},
'participations': {},
'submissions': {}
\"timestamp\": {},
\"active_sessions\": {},
\"active_participations\": {},
\"sessions\": {},
\"users\": {},
\"pms_users\": {},
\"teachers\": {},
\"participations\": {},
\"submissions\": {},
\"participations_by_contest_id\": {{
{}
}}
}}
",
now.sec, n_asession, n_apart, n_session, n_user, n_pmsuser, n_teacher, n_part, n_sub
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 ")
)
}
......
......@@ -1220,20 +1220,30 @@ impl MedalConnection for Connection {
FROM submission;";
let n_sub: i64 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT contest, count(*)
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();
format!(
"{{
'timestamp': {},
'active_sessions': {},
'active_participations': {},
'sessions': {},
'users': {},
'pms_users': {},
'teachers': {},
'participations': {},
'submissions': {}
\"timestamp\": {},
\"active_sessions\": {},
\"active_participations\": {},
\"sessions\": {},
\"users\": {},
\"pms_users\": {},
\"teachers\": {},
\"participations\": {},
\"submissions\": {},
\"participations_by_contest_id\": {{
{}
}}
}}
",
now.sec, n_asession, n_apart, n_session, n_user, n_pmsuser, n_teacher, n_part, n_sub
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 ")
)
}
......
......@@ -1220,20 +1220,30 @@ impl MedalConnection for Connection {
FROM submission;";
let n_sub: i64 = self.query_map_one(query, &[], |row| row.get(0)).unwrap().unwrap();
let query = "SELECT contest, count(*)
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();
format!(
"{{
'timestamp': {},
'active_sessions': {},
'active_participations': {},
'sessions': {},
'users': {},
'pms_users': {},
'teachers': {},
'participations': {},
'submissions': {}
\"timestamp\": {},
\"active_sessions\": {},
\"active_participations\": {},
\"sessions\": {},
\"users\": {},
\"pms_users\": {},
\"teachers\": {},
\"participations\": {},
\"submissions\": {},
\"participations_by_contest_id\": {{
{}
}}
}}
",
now.sec, n_asession, n_apart, n_session, n_user, n_pmsuser, n_teacher, n_part, n_sub
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