From e33f17c0495dd5306feddc22642322cf18fd1e9c Mon Sep 17 00:00:00 2001 From: D2SD Date: Mon, 4 May 2020 10:36:24 -0400 Subject: [PATCH 1/8] replace variable initialization --- tesseract-clickhouse/src/sql/rate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tesseract-clickhouse/src/sql/rate.rs b/tesseract-clickhouse/src/sql/rate.rs index f301e203..1ce6afe4 100644 --- a/tesseract-clickhouse/src/sql/rate.rs +++ b/tesseract-clickhouse/src/sql/rate.rs @@ -41,7 +41,7 @@ pub fn rate_calculation( primary_agg(table, cuts, &new_drills, meas, None) }; - let mut rate_sql = "".to_string(); + let mut rate_sql; // Wrap that around a pivot let original_drill_cols = drills.iter().map(|drill| drill.col_alias_only_string()); From 8cf64fa5e0529aee7a97eb4514b096a8d20ce977 Mon Sep 17 00:00:00 2001 From: D2SD Date: Mon, 4 May 2020 10:48:50 -0400 Subject: [PATCH 2/8] add unused variable prefix, remove unused modules --- tesseract-core/src/backend.rs | 2 +- tesseract-server/src/handlers/diagnosis.rs | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/tesseract-core/src/backend.rs b/tesseract-core/src/backend.rs index 84fb7e91..84a1a8fc 100644 --- a/tesseract-core/src/backend.rs +++ b/tesseract-core/src/backend.rs @@ -14,7 +14,7 @@ pub trait Backend { /// Takes in a SQL string, outputs a stream of /// DataFrames, which will go on to be formatted into the /// desired query output format. - fn exec_sql_stream(&self, sql: String) -> Box, Error=Error>> { + fn exec_sql_stream(&self, _sql: String) -> Box, Error=Error>> { unimplemented!() } diff --git a/tesseract-server/src/handlers/diagnosis.rs b/tesseract-server/src/handlers/diagnosis.rs index 2bf5b290..bc48bc52 100644 --- a/tesseract-server/src/handlers/diagnosis.rs +++ b/tesseract-server/src/handlers/diagnosis.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::str; use actix_web::{ @@ -7,22 +6,18 @@ use actix_web::{ Path, Result as ActixResult, }; -use failure::{Error, format_err}; +use failure::Error; use futures::future::Future; use lazy_static::lazy_static; use log::*; use serde_qs as qs; use serde_derive::Deserialize; -use url::Url; -use tesseract_core::names::{Property, LevelName}; use tesseract_core::format::{format_records, FormatType}; use tesseract_core::{DataFrame, Column, ColumnData}; -use tesseract_core::schema::{Cube, DimensionType, Level}; +use tesseract_core::schema::{Cube, Level}; use crate::app::AppState; -use crate::logic_layer::{LogicLayerConfig, CubeCache}; use crate::handlers::util::{verify_authorization, format_to_content_type}; -use crate::handlers::logic_layer::{query_geoservice, GeoserviceQuery}; /// Handles default aggregation when a format is not specified. @@ -37,7 +32,7 @@ pub fn diagnosis_default_handler( /// Handles aggregation when a format is specified. pub fn diagnosis_handler( - (req, cube_format): (HttpRequest, Path<(String)>) + (req, cube_format): (HttpRequest, Path) ) -> ActixResult { perform_diagnosis(req, cube_format.to_owned()) @@ -99,7 +94,7 @@ pub fn perform_diagnosis( let mut error_messages: Vec = vec![]; for cube in &schema.cubes { - if let Err(err) = verify_authorization(&req, cube.min_auth_level) { + if let Err(_err) = verify_authorization(&req, cube.min_auth_level) { continue; } @@ -109,7 +104,7 @@ pub fn perform_diagnosis( if new_error_types.len() != 0 { let mut new_error_cubes: Vec = vec![]; - for i in 0..new_error_types.len() { + for _i in 0..new_error_types.len() { new_error_cubes.push(cube.name.clone()); } @@ -171,7 +166,7 @@ fn diagnose_cube(req: &HttpRequest, cube: &Cube) -> (Vec, Vec< None => () } }, - Err(err) => () + Err(_err) => () } // Check for `NonUniqueDimensionIDs` @@ -204,7 +199,7 @@ fn diagnose_cube(req: &HttpRequest, cube: &Cube) -> (Vec, Vec< None => () } }, - Err(err) => () + Err(_err) => () } } } From b0d3cca9197aaa43488687e70f90adeb7027c908 Mon Sep 17 00:00:00 2001 From: D2SD Date: Mon, 4 May 2020 10:49:11 -0400 Subject: [PATCH 3/8] comment unused function --- tesseract-core/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tesseract-core/src/lib.rs b/tesseract-core/src/lib.rs index 355ad590..d1a7f497 100644 --- a/tesseract-core/src/lib.rs +++ b/tesseract-core/src/lib.rs @@ -1257,7 +1257,7 @@ impl Schema { Ok(column) } - fn get_mea_col(&self, cube_name: &str, measure: &Measure) -> Result { + /* fn get_mea_col(&self, cube_name: &str, measure: &Measure) -> Result { let cube = self.cubes.iter() .find(|cube| &cube.name == &cube_name) .ok_or(format_err!("Could not find cube"))?; @@ -1269,7 +1269,7 @@ impl Schema { let column = mea.column.clone(); Ok(column) - } + } */ pub fn get_cube_by_name(&self, cube_name: &str) -> Result<&Cube, Error> { self.cubes.iter() From bf47d52664491b4ae61b73f53426d2320944f0b6 Mon Sep 17 00:00:00 2001 From: D2SD Date: Mon, 4 May 2020 10:55:37 -0400 Subject: [PATCH 4/8] remove unnecessary parentheses --- tesseract-server/src/handlers/logic_layer/aggregate.rs | 2 +- tesseract-server/src/handlers/logic_layer/metadata.rs | 2 +- tesseract-server/src/handlers/logic_layer/mod.rs | 4 ++-- tesseract-server/src/handlers/logic_layer/relations.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tesseract-server/src/handlers/logic_layer/aggregate.rs b/tesseract-server/src/handlers/logic_layer/aggregate.rs index af1624fe..72d9c1ad 100644 --- a/tesseract-server/src/handlers/logic_layer/aggregate.rs +++ b/tesseract-server/src/handlers/logic_layer/aggregate.rs @@ -65,7 +65,7 @@ pub fn logic_layer_default_handler( /// Handles aggregation when a format is specified. pub fn logic_layer_handler( - (req, cube_format): (HttpRequest, Path<(String)>) + (req, cube_format): (HttpRequest, Path) ) -> FutureResponse { logic_layer_aggregation(req, cube_format.to_owned()) diff --git a/tesseract-server/src/handlers/logic_layer/metadata.rs b/tesseract-server/src/handlers/logic_layer/metadata.rs index ccdca4e2..6bda3d34 100644 --- a/tesseract-server/src/handlers/logic_layer/metadata.rs +++ b/tesseract-server/src/handlers/logic_layer/metadata.rs @@ -36,7 +36,7 @@ pub fn logic_layer_members_default_handler( /// Handles members query when a format is specified. pub fn logic_layer_members_handler( - (req, cube_format): (HttpRequest, Path<(String)>) + (req, cube_format): (HttpRequest, Path) ) -> FutureResponse { get_members(req, cube_format.to_owned()) diff --git a/tesseract-server/src/handlers/logic_layer/mod.rs b/tesseract-server/src/handlers/logic_layer/mod.rs index 97712adf..e31aa7ca 100644 --- a/tesseract-server/src/handlers/logic_layer/mod.rs +++ b/tesseract-server/src/handlers/logic_layer/mod.rs @@ -37,7 +37,7 @@ pub fn logic_layer_non_unique_levels_default_handler( pub fn logic_layer_non_unique_levels_handler( - (req, _cube): (HttpRequest, Path<(String)>), + (req, _cube): (HttpRequest, Path), ) -> HttpResponse { if req.state().debug { @@ -71,7 +71,7 @@ pub fn logic_layer_relations_non_unique_levels_default_handler( pub fn logic_layer_relations_non_unique_levels_handler( - (req, _cube): (HttpRequest, Path<(String)>), + (req, _cube): (HttpRequest, Path), ) -> HttpResponse { if req.state().debug { diff --git a/tesseract-server/src/handlers/logic_layer/relations.rs b/tesseract-server/src/handlers/logic_layer/relations.rs index 9abab813..ec63e368 100644 --- a/tesseract-server/src/handlers/logic_layer/relations.rs +++ b/tesseract-server/src/handlers/logic_layer/relations.rs @@ -36,7 +36,7 @@ pub fn logic_layer_relations_default_handler( /// Handles aggregation when a format is specified. pub fn logic_layer_relations_handler( - (req, cube_format): (HttpRequest, Path<(String)>) + (req, cube_format): (HttpRequest, Path) ) -> ActixResult { logic_layer_relations(req, cube_format.to_owned()) From 4c5e269230c59581acdc0e15e8940a49c1c6a96a Mon Sep 17 00:00:00 2001 From: D2SD Date: Mon, 4 May 2020 10:57:58 -0400 Subject: [PATCH 5/8] add explicit 'dyn' to trait object --- tesseract-mysql/src/df.rs | 2 +- tesseract-mysql/src/lib.rs | 2 +- tesseract-postgres/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tesseract-mysql/src/df.rs b/tesseract-mysql/src/df.rs index 23317cdf..f34b7235 100644 --- a/tesseract-mysql/src/df.rs +++ b/tesseract-mysql/src/df.rs @@ -8,7 +8,7 @@ use mysql_async::Value::*; use std::str; use tesseract_core::{DataFrame, Column, ColumnData}; -pub fn rows_to_df(query_result: QueryResult) -> Box> { +pub fn rows_to_df(query_result: QueryResult) -> Box< dyn Future> { let mut tcolumn_list = vec![]; let columns = query_result.columns_ref(); diff --git a/tesseract-mysql/src/lib.rs b/tesseract-mysql/src/lib.rs index 3ab308f5..c822d8dd 100644 --- a/tesseract-mysql/src/lib.rs +++ b/tesseract-mysql/src/lib.rs @@ -26,7 +26,7 @@ impl MySql { } impl Backend for MySql { - fn exec_sql(&self, sql: String) -> Box> { + fn exec_sql(&self, sql: String) -> Box< dyn Future> { let future = self.pool.get_conn() .and_then(move |conn| { conn.prep_exec(sql.to_string(), ()) diff --git a/tesseract-postgres/src/lib.rs b/tesseract-postgres/src/lib.rs index f9f3bad3..0071d3a2 100644 --- a/tesseract-postgres/src/lib.rs +++ b/tesseract-postgres/src/lib.rs @@ -55,7 +55,7 @@ impl Postgres { // 2. dataframe creation impl Backend for Postgres { - fn exec_sql(&self, sql: String) -> Box> { + fn exec_sql(&self, sql: String) -> Box< dyn Future> { let fut = self.pool.run(move |mut connection| { connection.prepare(&sql).then( |r| match r { Ok(select) => { From 0c5e28ca4717a4895b9d5f52295bffad30744af3 Mon Sep 17 00:00:00 2001 From: D2SD Date: Mon, 4 May 2020 11:10:33 -0400 Subject: [PATCH 6/8] removes unreachable patterns --- tesseract-core/src/format_stream.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tesseract-core/src/format_stream.rs b/tesseract-core/src/format_stream.rs index af0b65a5..f7067151 100644 --- a/tesseract-core/src/format_stream.rs +++ b/tesseract-core/src/format_stream.rs @@ -1,6 +1,6 @@ use bytes::Bytes; use csv; -use failure::{Error, format_err}; +use failure::Error; use futures::{Stream, Async, Poll}; use indexmap::IndexMap; use serde::Serializer; @@ -117,8 +117,7 @@ impl Stream for RecordBlockStream self.sent_header = true; return Ok(Async::Ready(Some(bytes))); - }, - _ => return Err(format_err!("just csv first")), + } } } @@ -147,8 +146,7 @@ impl Stream for RecordBlockStream FormatType::JsonArrays => { let res = b"]}".to_vec().into(); return Ok(Async::Ready(Some(res))); - }, - _ => return Err(format_err!("just csv first")), + } } }, }; @@ -198,7 +196,6 @@ impl Stream for RecordBlockStream return Ok(Async::Ready(Some(body))); } - _ => return Err(format_err!("just csv first")), }; return Ok(Async::Ready(Some(formatted))); From ce151d52751bddb835dc784bdb487f692089a65e Mon Sep 17 00:00:00 2001 From: D2SD Date: Wed, 3 Jun 2020 10:15:33 -0400 Subject: [PATCH 7/8] remove unused method --- tesseract-core/src/lib.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tesseract-core/src/lib.rs b/tesseract-core/src/lib.rs index d1a7f497..45301bbe 100644 --- a/tesseract-core/src/lib.rs +++ b/tesseract-core/src/lib.rs @@ -1257,20 +1257,6 @@ impl Schema { Ok(column) } - /* fn get_mea_col(&self, cube_name: &str, measure: &Measure) -> Result { - let cube = self.cubes.iter() - .find(|cube| &cube.name == &cube_name) - .ok_or(format_err!("Could not find cube"))?; - - let mea = cube.measures.iter() - .find(|m| m.name == measure.0) - .ok_or(format_err!("could not find level for level name"))?; - - let column = mea.column.clone(); - - Ok(column) - } */ - pub fn get_cube_by_name(&self, cube_name: &str) -> Result<&Cube, Error> { self.cubes.iter() .find(|c| &c.name == &cube_name) From 9d1308f162a4177b1751b1873bc28a8841f20e5e Mon Sep 17 00:00:00 2001 From: D2SD Date: Wed, 3 Jun 2020 10:26:42 -0400 Subject: [PATCH 8/8] fix conflicts --- tesseract-server/src/handlers/diagnosis.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tesseract-server/src/handlers/diagnosis.rs b/tesseract-server/src/handlers/diagnosis.rs index bc48bc52..a1e8e10b 100644 --- a/tesseract-server/src/handlers/diagnosis.rs +++ b/tesseract-server/src/handlers/diagnosis.rs @@ -166,7 +166,7 @@ fn diagnose_cube(req: &HttpRequest, cube: &Cube) -> (Vec, Vec< None => () } }, - Err(_err) => () + Err(_) => () } // Check for `NonUniqueDimensionIDs` @@ -199,7 +199,7 @@ fn diagnose_cube(req: &HttpRequest, cube: &Cube) -> (Vec, Vec< None => () } }, - Err(_err) => () + Err(_) => () } } }