Skip to content

Commit

Permalink
GROUP_CONCAT hack for file results
Browse files Browse the repository at this point in the history
  • Loading branch information
Magnus Manske committed Jan 20, 2020
1 parent 8fb5c96 commit 8fd0272
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/app_state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extern crate rocket;

use crate::datasource::SQLtuple;
use crate::form_parameters::FormParameters;
use crate::platform::MyResponse;
use chrono::prelude::*;
Expand Down Expand Up @@ -189,6 +190,23 @@ impl AppState {
}
}

fn set_group_concat_max_len(&self, wiki: &String, conn: &mut my::Conn) -> Result<(), String> {
if wiki != "commonswiki" {
return Ok(()); // Only needed for commonswiki, in platform::process_files
}
let sql: SQLtuple = (
"SET SESSION group_concat_max_len = 1000000000".to_string(),
vec![],
);
conn.prep_exec(&sql.0, &sql.1).map_err(|e| {
format!(
"AppState::set_group_concat_max_len: SQL query error: {:?}",
e
)
})?;
Ok(())
}

pub fn get_wiki_db_connection(
&self,
db_user_pass: &DbUserPass,
Expand All @@ -208,7 +226,10 @@ impl AppState {
builder.tcp_port(self.config["db_port"].as_u64().unwrap_or(3306) as u16);

match my::Conn::new(builder) {
Ok(con) => return Ok(con),
Ok(mut con) => {
self.set_group_concat_max_len(wiki, &mut con)?;
return Ok(con);
}
Err(e) => {
println!("CONNECTION ERROR: {:?}", e);
if loops_left == 0 {
Expand Down

0 comments on commit 8fd0272

Please sign in to comment.