diff --git a/Cargo.toml b/Cargo.toml index 21fe9e80..a27f2872 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garmin_rust" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2018" @@ -26,7 +26,7 @@ garmin_utils = {path="garmin_utils"} log = "0.4" stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.3" } tempdir = "0.3" -tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]} +tokio = {version="1.38", features=["rt", "macros", "rt-multi-thread"]} [workspace] members = [ diff --git a/fitbit_bot/Cargo.toml b/fitbit_bot/Cargo.toml index 5421cc00..45359301 100644 --- a/fitbit_bot/Cargo.toml +++ b/fitbit_bot/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fitbit_bot" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2018" @@ -19,10 +19,10 @@ once_cell = "1.0" parking_lot = "0.12" stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.3" } telegram-bot = {git = "https://github.com/ddboline/telegram-bot.git", tag="0.9.0-4", default_features=false} -tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]} +tokio = {version="1.38", features=["rt", "macros", "rt-multi-thread"]} [dev-dependencies] maplit = "1.0" rand = "0.8" -postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]} +postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.8", features=["deadpool"]} uuid = { version = "1.0", features = ["serde", "v4"] } diff --git a/fitbit_bot/src/telegram_bot.rs b/fitbit_bot/src/telegram_bot.rs index 4ea88363..4e87d468 100644 --- a/fitbit_bot/src/telegram_bot.rs +++ b/fitbit_bot/src/telegram_bot.rs @@ -236,7 +236,7 @@ mod tests { let user: UserId = 8675309.into(); let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let bot = TelegramBot::new("8675309", &pool, &config); @@ -302,7 +302,7 @@ mod tests { let mut exp = ScaleMeasurement::from_telegram_text(msg)?; let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let bot = TelegramBot::new("8675309", &pool, &config); exp.insert_into_db(&pool).await?; @@ -333,7 +333,7 @@ mod tests { USERIDS.store(Arc::new(HashSet::new())); let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let bot = TelegramBot::new("8675309", &pool, &config); let email = format_sstr!("user{}@localhost", get_random_string(32)); diff --git a/fitbit_lib/Cargo.toml b/fitbit_lib/Cargo.toml index bfd62497..228efc8b 100644 --- a/fitbit_lib/Cargo.toml +++ b/fitbit_lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fitbit_lib" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2018" @@ -19,12 +19,12 @@ garmin_lib = {path = "../garmin_lib"} garmin_models = {path="../garmin_models"} garmin_utils = {path="../garmin_utils"} glob = "0.3" -itertools = "0.12" +itertools = "0.13" log = "0.4" maplit = "1.0" once_cell = "1.0" -polars = {version="0.39", features=["temporal", "parquet", "lazy"]} -postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]} +polars = {version="0.41", features=["temporal", "parquet", "lazy"]} +postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.8", features=["deadpool"]} rand = "0.8" rayon = "1.5" reqwest = {version="0.12", features=["cookies", "json", "rustls-tls", "stream"], default_features=false} @@ -35,7 +35,7 @@ stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", featur statistical = "1.0" time = {version="0.3", features=["serde-human-readable", "macros", "formatting", "parsing"]} time-tz = {version="2.0", features=["system"]} -tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]} +tokio = {version="1.38", features=["rt", "macros", "rt-multi-thread"]} uuid = { version = "1.0", features = ["serde", "v4"] } [dev-dependencies] diff --git a/fitbit_lib/src/fitbit_client.rs b/fitbit_lib/src/fitbit_client.rs index 0cc7fddf..705a338d 100644 --- a/fitbit_lib/src/fitbit_client.rs +++ b/fitbit_lib/src/fitbit_client.rs @@ -1135,10 +1135,7 @@ mod tests { use log::debug; use std::collections::HashMap; use tempfile::NamedTempFile; - use time::{ - macros::{date, format_description}, - Date, Duration, OffsetDateTime, - }; + use time::{macros::format_description, Duration, OffsetDateTime}; use time_tz::OffsetDateTimeExt; use garmin_lib::{date_time_wrapper::DateTimeWrapper, garmin_config::GarminConfig}; @@ -1242,7 +1239,7 @@ mod tests { let begin_datetime = OffsetDateTime::now_utc() - Duration::days(30); - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let dates = client.sync_fitbit_activities(begin_datetime, &pool).await?; debug!("{:?}", dates); assert_eq!(dates.len(), 0); @@ -1265,7 +1262,7 @@ mod tests { async fn test_dump_fitbit_activities() -> Result<(), Error> { let config = GarminConfig::get_config(None)?; let client = FitbitClient::with_auth(config.clone()).await?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let mut activities: HashMap<_, _> = FitbitActivity::read_from_db(&pool, None, None) .await? .into_iter() @@ -1301,7 +1298,7 @@ mod tests { #[ignore] async fn test_delete_duplicate_activities() -> Result<(), Error> { let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let client = FitbitClient::with_auth(config.clone()).await?; let output = client.remove_duplicate_entries(&pool).await?; diff --git a/fitbit_lib/src/fitbit_heartrate.rs b/fitbit_lib/src/fitbit_heartrate.rs index 77e9d664..e5b8aed8 100644 --- a/fitbit_lib/src/fitbit_heartrate.rs +++ b/fitbit_lib/src/fitbit_heartrate.rs @@ -585,7 +585,7 @@ mod tests { #[ignore] async fn test_calculate_summary_statistics() -> Result<(), Error> { let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let start_date = date!(2019 - 08 - 01); let result = FitbitHeartRate::calculate_summary_statistics(&config, &pool, start_date).await?; diff --git a/fitbit_lib/src/scale_measurement.rs b/fitbit_lib/src/scale_measurement.rs index a531b49f..3ca94033 100644 --- a/fitbit_lib/src/scale_measurement.rs +++ b/fitbit_lib/src/scale_measurement.rs @@ -366,7 +366,7 @@ mod tests { }; let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; exp.insert_into_db(&pool).await?; diff --git a/garmin_cli/Cargo.toml b/garmin_cli/Cargo.toml index 2fdb0cab..984f300d 100644 --- a/garmin_cli/Cargo.toml +++ b/garmin_cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garmin_cli" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2018" @@ -18,7 +18,7 @@ garmin_models={path="../garmin_models"} garmin_parser={path="../garmin_parser"} garmin_reports = {path="../garmin_reports"} garmin_utils={path="../garmin_utils"} -itertools = "0.12" +itertools = "0.13" log = "0.4" race_result_analysis = {path="../race_result_analysis"} rayon = "1.5" @@ -30,7 +30,7 @@ strava_lib = {path="../strava_lib"} tempdir = "0.3" time = {version="0.3", features=["serde-human-readable", "macros", "formatting", "parsing"]} time-tz = {version="2.0", features=["system"]} -tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]} +tokio = {version="1.38", features=["rt", "macros", "rt-multi-thread"]} tokio-postgres = {version = "0.7", features = ["with-time-0_3"]} stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.3" } stdout-channel = "0.6" diff --git a/garmin_cli/src/garmin_cli.rs b/garmin_cli/src/garmin_cli.rs index 508ca600..32c2c7bc 100644 --- a/garmin_cli/src/garmin_cli.rs +++ b/garmin_cli/src/garmin_cli.rs @@ -77,7 +77,7 @@ impl GarminCli { /// Return error if config init fails pub fn with_config() -> Result { let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let corr = GarminCorrectionMap::new(); let obj = Self { config, @@ -152,6 +152,7 @@ impl GarminCli { &self, corr_map: &HashMap<(DateTimeWrapper, i32), GarminCorrectionLap>, ) -> Result, Error> { + let config = self.get_config(); let pg_conn = self.get_pool(); let mut gsum_list: Vec<_> = match self.get_opts() { @@ -159,16 +160,14 @@ impl GarminCli { .par_iter() .map(|f| { self.stdout.send(format_sstr!("Process {f:?}")); - GarminParse::process_single_gps_file(f, &self.get_config().cache_dir, corr_map) + GarminParse::process_single_gps_file(f, &config.cache_dir, corr_map) }) .collect::, Error>>()?, - Some(GarminCliOptions::All) => GarminParse::process_all_gps_files( - &self.get_config().gps_dir, - &self.get_config().cache_dir, - corr_map, - )?, + Some(GarminCliOptions::All) => { + GarminParse::process_all_gps_files(&config.gps_dir, &config.cache_dir, corr_map)? + } _ => { - let cacheset: HashSet = get_file_list(&self.get_config().cache_dir) + let cacheset: HashSet = get_file_list(&config.cache_dir) .into_par_iter() .filter_map(|f| { if f.to_string_lossy().contains("garmin_correction.avro") { @@ -185,7 +184,7 @@ impl GarminCli { .try_collect() .await?; - get_file_list(&self.get_config().gps_dir) + get_file_list(&config.gps_dir) .into_par_iter() .filter_map(|f| f.file_name().map(|x| x.to_string_lossy().to_string())) .filter_map(|f| { @@ -193,18 +192,12 @@ impl GarminCli { if dbset.contains(f.as_str()) && cacheset.contains(cachefile.as_str()) { None } else { - let gps_path = self.get_config().gps_dir.join(&f); + let gps_path = config.gps_dir.join(&f); debug!("Process {:?}", &gps_path); Some(gps_path) } }) - .map(|f| { - GarminParse::process_single_gps_file( - &f, - &self.get_config().cache_dir, - corr_map, - ) - }) + .map(|f| GarminParse::process_single_gps_file(&f, &config.cache_dir, corr_map)) .collect::, Error>>()? } }; @@ -221,29 +214,26 @@ impl GarminCli { /// # Errors /// Return error if `sync_dir` fails pub async fn sync_everything(&self) -> Result, Error> { + let config = self.get_config(); let sdk_config = aws_config::load_from_env().await; let gsync = GarminSync::new(&sdk_config); let options = vec![ - ( - "Syncing GPS files", - &self.get_config().gps_dir, - &self.get_config().gps_bucket, - ), + ("Syncing GPS files", &config.gps_dir, &config.gps_bucket), ( "Syncing CACHE files", - &self.get_config().cache_dir, - &self.get_config().cache_bucket, + &config.cache_dir, + &config.cache_bucket, ), ( "Syncing Fitbit Cache", - &self.get_config().fitbit_cachedir, - &self.get_config().fitbit_bucket, + &config.fitbit_cachedir, + &config.fitbit_bucket, ), ( "Syncing Fitbit Archive", - &self.get_config().fitbit_archivedir, - &self.get_config().fitbit_archive_bucket, + &config.fitbit_archivedir, + &config.fitbit_archive_bucket, ), ]; @@ -282,6 +272,7 @@ impl GarminCli { options: &GarminReportOptions, constraints: &GarminConstraints, ) -> Result<(), Error> { + let config = self.get_config(); let pg_conn = self.get_pool(); let mut file_list: Vec<_> = get_list_of_files_from_db(&constraints.to_query_string(), &pg_conn) @@ -309,7 +300,7 @@ impl GarminCli { debug!("Cached avro file read: {:?}", &avro_file); g } else { - let gps_file = self.get_config().gps_dir.join(file_name.as_str()); + let gps_file = config.gps_dir.join(file_name.as_str()); let pool = self.get_pool(); let mut corr_map = GarminCorrectionLap::read_corrections_from_db(&pool).await?; corr_map.shrink_to_fit(); diff --git a/garmin_cli/src/garmin_cli_opts.rs b/garmin_cli/src/garmin_cli_opts.rs index 1306beb5..d60a105c 100644 --- a/garmin_cli/src/garmin_cli_opts.rs +++ b/garmin_cli/src/garmin_cli_opts.rs @@ -160,7 +160,7 @@ impl GarminCliOpts { } async fn process_opts(self, config: &GarminConfig) -> Result<(), Error> { - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let opts = match self { Self::Bootstrap => GarminCliOptions::Bootstrap, @@ -666,7 +666,7 @@ mod tests { async fn test_garmin_file_test_filenames() -> Result<(), Error> { let test_config = "tests/data/test.env"; let config = GarminConfig::get_config(Some(test_config))?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let corr = GarminCorrectionMap::new(); let gcli = GarminCli { diff --git a/garmin_connect_lib/Cargo.toml b/garmin_connect_lib/Cargo.toml index 22bcb1d0..54076e63 100644 --- a/garmin_connect_lib/Cargo.toml +++ b/garmin_connect_lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garmin_connect_lib" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2018" @@ -13,7 +13,7 @@ derive_more = "0.99" fantoccini = {version="0.19", features=["rustls-tls"], default_features=false} futures = "0.3" garmin_lib = {path="../garmin_lib"} -itertools = "0.12" +itertools = "0.13" log = "0.4" reqwest = {version="0.12", features=["cookies", "json", "rustls-tls", "stream"], default_features=false} serde = {version="1.0", features=["derive"]} @@ -22,5 +22,5 @@ smallvec = "1.6" stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.3" } time = {version="0.3", features=["serde-human-readable", "macros", "formatting", "parsing"]} time-tz = {version="2.0", features=["system"]} -tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]} +tokio = {version="1.38", features=["rt", "macros", "rt-multi-thread"]} url = "2.3" diff --git a/garmin_http/Cargo.toml b/garmin_http/Cargo.toml index 158de7c6..0924325b 100644 --- a/garmin_http/Cargo.toml +++ b/garmin_http/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "garmin_http" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2018" [dependencies] anyhow = "1.0" -authorized_users = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.14"} +authorized_users = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.15"} base64 = "0.22" cookie = {version="0.18", features=["percent-encode"]} derive_more = "0.99" @@ -22,11 +22,11 @@ garmin_parser = {path="../garmin_parser"} garmin_reports = {path="../garmin_reports"} garmin_utils = {path="../garmin_utils"} handlebars = "5.1" -itertools = "0.12" +itertools = "0.13" log = "0.4" maplit = "1.0" parking_lot = "0.12" -postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]} +postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.8", features=["deadpool"]} race_result_analysis = {path="../race_result_analysis"} reqwest = {version="0.12", features=["cookies", "json", "rustls-tls", "stream"], default_features=false} rweb = {git = "https://github.com/ddboline/rweb.git", features=["openapi"], default-features=false, tag="0.15.2"} @@ -41,7 +41,7 @@ tempdir = "0.3" thiserror = "1.0" time = {version="0.3", features=["serde-human-readable", "macros", "formatting", "parsing"]} time-tz = {version="2.0", features=["system"]} -tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]} +tokio = {version="1.38", features=["rt", "macros", "rt-multi-thread"]} tokio-stream = "0.1" url = "2.3" uuid = "1.0" diff --git a/garmin_http/src/garmin_elements.rs b/garmin_http/src/garmin_elements.rs index f66728f2..52e91648 100644 --- a/garmin_http/src/garmin_elements.rs +++ b/garmin_http/src/garmin_elements.rs @@ -415,7 +415,7 @@ fn IndexElement( ); let mut final_values: Vec<_> = heartrate .iter() - .group_by(|(d, _)| d.unix_timestamp() / (5 * 60)) + .chunk_by(|(d, _)| d.unix_timestamp() / (5 * 60)) .into_iter() .map(|(_, group)| { let (begin_datetime, entries, heartrate_sum) = group.fold( diff --git a/garmin_http/src/garmin_rust_app.rs b/garmin_http/src/garmin_rust_app.rs index d1323181..883b61d1 100644 --- a/garmin_http/src/garmin_rust_app.rs +++ b/garmin_http/src/garmin_rust_app.rs @@ -95,7 +95,7 @@ pub async fn start_app() -> Result<(), Error> { TRIGGER_DB_UPDATE.set(); get_secrets(&config.secret_path, &config.jwt_secret_path).await?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; spawn({ let pool = pool.clone(); diff --git a/garmin_lib/Cargo.toml b/garmin_lib/Cargo.toml index d52ca1e3..d4611cb4 100644 --- a/garmin_lib/Cargo.toml +++ b/garmin_lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garmin_lib" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2018" diff --git a/garmin_models/Cargo.toml b/garmin_models/Cargo.toml index aa5215f1..1bc30da4 100644 --- a/garmin_models/Cargo.toml +++ b/garmin_models/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garmin_models" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2021" @@ -15,19 +15,19 @@ fitparser = {git="https://github.com/ddboline/fitparse-rs.git", branch="time-0.3 futures = "0.3" garmin_lib = {path="../garmin_lib"} garmin_utils = {path="../garmin_utils"} -itertools = "0.12" +itertools = "0.13" json = "0.12" log = "0.4" once_cell = "1.0" -postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]} +postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.8", features=["deadpool"]} rand = "0.8" -roxmltree = "0.19" +roxmltree = "0.20" serde = {version="1.0", features=["derive"]} serde_json = "1.0" stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.3" } time = {version="0.3", features=["serde-human-readable", "macros", "formatting", "parsing"]} time-tz = {version="2.0", features=["system"]} -tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]} +tokio = {version="1.38", features=["rt", "macros", "rt-multi-thread"]} uuid = { version = "1.0", features = ["serde", "v4"] } url = "2.3" diff --git a/garmin_models/src/garmin_connect_activity.rs b/garmin_models/src/garmin_connect_activity.rs index 00f71c05..bfa26046 100644 --- a/garmin_models/src/garmin_connect_activity.rs +++ b/garmin_models/src/garmin_connect_activity.rs @@ -249,7 +249,7 @@ impl GarminConnectActivity { /// Return error if serialization fails pub async fn import_garmin_connect_activity_json_file(filename: &Path) -> Result<(), Error> { let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; if !filename.exists() { return Err(format_err!("file {filename:?} does not exist")); } diff --git a/garmin_parser/Cargo.toml b/garmin_parser/Cargo.toml index 95e7fbd1..c5202c3d 100644 --- a/garmin_parser/Cargo.toml +++ b/garmin_parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garmin_parser" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2021" @@ -18,7 +18,7 @@ garmin_utils = {path="../garmin_utils"} log = "0.4" postgres-types = {version="0.2", features=["with-time-0_3", "with-uuid-1", "with-serde_json-1", "derive"]} rayon = "1.5" -roxmltree = "0.19" +roxmltree = "0.20" serde = {version="1.0", features=["derive"]} serde_json = "1.0" smallvec = "1.6" diff --git a/garmin_reports/Cargo.toml b/garmin_reports/Cargo.toml index 36277c06..ee0cf34b 100644 --- a/garmin_reports/Cargo.toml +++ b/garmin_reports/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garmin_reports" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2018" @@ -13,10 +13,10 @@ futures = "0.3" garmin_lib = {path="../garmin_lib"} garmin_models = {path="../garmin_models"} garmin_utils = {path="../garmin_utils"} -itertools = "0.12" +itertools = "0.13" log = "0.4" once_cell = "1.0" -postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]} +postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.8", features=["deadpool"]} regex = "1.4" stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types", "rweb-openapi"], tag="0.9.3" } time = {version="0.3", features=["serde-human-readable", "macros", "formatting", "parsing"]} diff --git a/garmin_utils/Cargo.toml b/garmin_utils/Cargo.toml index 39c3e6c2..7738b78c 100644 --- a/garmin_utils/Cargo.toml +++ b/garmin_utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garmin_utils" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2021" @@ -10,14 +10,14 @@ edition = "2021" anyhow = "1.0" base64 = "0.22" bytes = "1.0" -deadpool-postgres = "0.13" +deadpool-postgres = "0.14" fitparser = {git="https://github.com/ddboline/fitparse-rs.git", branch="time-0.3-0.5.2"} flate2 = "1.0" futures = "0.3" log = "0.4" num-traits = "0.2" once_cell = "1.0" -postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]} +postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.8", features=["deadpool"]} rand = "0.8" serde = {version="1.0", features=["derive"]} smallvec = "1.6" @@ -26,11 +26,11 @@ subprocess = "0.2" tempdir = "0.3" time = {version="0.3", features=["serde-human-readable", "macros", "formatting", "parsing"]} time-tz = {version="2.0", features=["system"]} -tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]} +tokio = {version="1.38", features=["rt", "macros", "rt-multi-thread"]} tokio-postgres = {version = "0.7", features = ["with-time-0_3", "with-uuid-1"]} url = "2.3" uuid = { version = "1.0", features = ["serde", "v4"] } -zip = {version = "1.2", default-features = false, features=["aes-crypto", "bzip2", "deflate", "deflate64", "lzma", "time", "zstd"]} +zip = {version = "2.1", default-features = false, features=["aes-crypto", "bzip2", "deflate", "deflate64", "lzma", "time", "zstd"]} [dev-dependencies] garmin_lib = {path="../garmin_lib"} diff --git a/garmin_utils/src/pgpool.rs b/garmin_utils/src/pgpool.rs index 8e0e8f6a..359856b3 100644 --- a/garmin_utils/src/pgpool.rs +++ b/garmin_utils/src/pgpool.rs @@ -20,10 +20,10 @@ impl fmt::Debug for PgPool { } impl PgPool { - #[allow(clippy::missing_panics_doc)] - #[must_use] - pub fn new(pgurl: &str) -> Self { - let pgconf: PgConfig = pgurl.parse().expect("Failed to parse Url"); + /// # Errors + /// Return error if pool setup fails + pub fn new(pgurl: &str) -> Result { + let pgconf: PgConfig = pgurl.parse()?; let mut config = Config::default(); @@ -42,17 +42,12 @@ impl PgPool { config.dbname.replace(db.to_string()); } - let pool = config - .builder(NoTls) - .unwrap_or_else(|_| panic!("failed to create builder")) - .max_size(4) - .build() - .unwrap_or_else(|_| panic!("Failed to create pool {pgurl}")); + let pool = config.builder(NoTls)?.max_size(4).build()?; - Self { + Ok(Self { pgurl: Arc::new(pgurl.into()), pool: Some(pool), - } + }) } /// # Errors diff --git a/race_result_analysis/Cargo.toml b/race_result_analysis/Cargo.toml index b0623078..c8709933 100644 --- a/race_result_analysis/Cargo.toml +++ b/race_result_analysis/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "race_result_analysis" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2018" @@ -13,18 +13,18 @@ futures = "0.3" garmin_lib = {path="../garmin_lib"} garmin_models = {path="../garmin_models"} garmin_utils = {path="../garmin_utils"} -itertools = "0.12" +itertools = "0.13" log = "0.4" ndarray = "0.15" parking_lot = "0.12" -postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]} +postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.8", features=["deadpool"]} rusfun = { git = "https://github.com/ddboline/rusfun.git" } serde = {version="1.0", features=["derive"]} smallvec = "1.6" stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.3" } time = {version="0.3", features=["serde-human-readable", "macros", "formatting", "parsing"]} time-tz = {version="2.0", features=["system"]} -tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]} +tokio = {version="1.38", features=["rt", "macros", "rt-multi-thread"]} tokio-postgres = {version = "0.7", features = ["with-time-0_3", "with-uuid-1"]} uuid = { version = "1.0", features = ["serde", "v4"] } diff --git a/race_result_analysis/src/race_result_analysis.rs b/race_result_analysis/src/race_result_analysis.rs index cd2b3fa2..90ac2bf1 100644 --- a/race_result_analysis/src/race_result_analysis.rs +++ b/race_result_analysis/src/race_result_analysis.rs @@ -263,7 +263,7 @@ mod tests { #[ignore] async fn test_get_aggregated_race_results() -> Result<(), Error> { let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let results = RaceResultAggregated::get_aggregated_race_results(RaceType::Personal, &pool).await?; diff --git a/race_result_analysis/src/race_results.rs b/race_result_analysis/src/race_results.rs index 1ce73759..8fd03d35 100644 --- a/race_result_analysis/src/race_results.rs +++ b/race_result_analysis/src/race_results.rs @@ -499,7 +499,7 @@ mod tests { let _ = DB_LOCK.lock(); let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let result = get_test_race_result(); debug!("{:?}", result); result.insert_into_db(&pool).await?; @@ -530,7 +530,7 @@ mod tests { let _ = DB_LOCK.lock(); let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let existing_map: HashMap<_, _> = RaceResults::get_results_by_type(RaceType::Personal, &pool) @@ -676,7 +676,7 @@ mod tests { let _ = DB_LOCK.lock(); let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; for mut result in mens_results.into_iter().chain(womens_results.into_iter()) { let existing = diff --git a/src/import_garmin_connect_data.rs b/src/import_garmin_connect_data.rs index 41f9bbc6..7e3040aa 100644 --- a/src/import_garmin_connect_data.rs +++ b/src/import_garmin_connect_data.rs @@ -41,7 +41,7 @@ async fn main() -> Result<(), Error> { env_logger::init(); let config = GarminConfig::get_config(None)?; let opts = JsonImportOpts::parse(); - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let mut dates = BTreeSet::new(); match opts { diff --git a/src/scale_measurement_bot.rs b/src/scale_measurement_bot.rs index c463cf5e..3b9165b6 100644 --- a/src/scale_measurement_bot.rs +++ b/src/scale_measurement_bot.rs @@ -15,7 +15,7 @@ use garmin_utils::pgpool::PgPool; async fn main() -> Result<(), Error> { env_logger::init(); let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(config.pgurl.as_str()); + let pool = PgPool::new(config.pgurl.as_str())?; if let Some(telegram_bot_token) = config.telegram_bot_token.as_ref() { TelegramBot::new(telegram_bot_token, &pool, &config) .run_bot() diff --git a/strava_lib/Cargo.toml b/strava_lib/Cargo.toml index 6badfcba..841a1dbf 100644 --- a/strava_lib/Cargo.toml +++ b/strava_lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strava_lib" -version = "0.14.17" +version = "0.14.18" authors = ["Daniel Boline "] edition = "2018" @@ -15,7 +15,7 @@ garmin_utils = {path="../garmin_utils"} log = "0.4" maplit = "1.0" once_cell = "1.0" -postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]} +postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.8", features=["deadpool"]} reqwest = {version="0.12", features=["cookies", "json", "rustls-tls", "stream", "multipart"], default_features=false} select = "0.6" serde = {version="1.0", features=["derive"]} @@ -24,6 +24,6 @@ stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", featur tempfile = "3.1" time = {version="0.3", features=["serde-human-readable", "macros", "formatting", "parsing"]} time-tz = {version="2.0", features=["system"]} -tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]} +tokio = {version="1.38", features=["rt", "macros", "rt-multi-thread"]} tokio-stream = "0.1" uuid = "1.0" diff --git a/strava_lib/src/strava_client.rs b/strava_lib/src/strava_client.rs index 0ec055dd..a7c5a661 100644 --- a/strava_lib/src/strava_client.rs +++ b/strava_lib/src/strava_client.rs @@ -873,7 +873,7 @@ mod tests { #[ignore] async fn test_dump_strava_activities() -> Result<(), Error> { let config = GarminConfig::get_config(None)?; - let pool = PgPool::new(&config.pgurl); + let pool = PgPool::new(&config.pgurl)?; let mut activities: HashMap<_, _> = StravaActivity::read_from_db(&pool, None, None) .await? .map_ok(|activity| (activity.id, activity))