Sync your own workout data from your "Strong" app
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cargo fmt and clippy

+12 -25
+6 -3
strong-api-dump/src/main.rs
··· 2 2 use reqwest::Url; 3 3 use std::env; 4 4 use strong_api_lib::data_transformer::DataTransformer; 5 - use strong_api_lib::json_response::{MeasurementsResponse, UserResponse}; 6 - use strong_api_lib::strong_api::{Includes, StrongApi}; 5 + use strong_api_lib::json_response::UserResponse; 6 + use strong_api_lib::strong_api::StrongApi; 7 7 8 8 #[tokio::main] 9 9 async fn main() -> Result<(), Box<dyn std::error::Error>> { 10 10 dotenv().ok(); 11 + 12 + #[allow(unused_variables)] 11 13 let username = env::var("STRONG_USER").expect("STRONG_USER must be set"); 14 + #[allow(unused_variables)] 12 15 let password = env::var("STRONG_PASS").expect("STRONG_PASS must be set"); 13 16 let strong_backend = env::var("STRONG_BACKEND").expect("STRONG_BACKEND must be set"); 14 17 let url = Url::parse(&strong_backend).expect("STRONG_BACKEND is not a valid URL"); ··· 58 61 }); 59 62 60 63 Ok(()) 61 - } 64 + }
+5 -19
strong-api-lib/src/data_transformer.rs
··· 1 - use crate::json_response::{CellSetGroupLinks, Log, Measurement, MeasurementsResponse, Name}; 1 + use crate::json_response::{CellSetGroupLinks, Log, Measurement, MeasurementsResponse}; 2 2 use std::collections::HashMap; 3 - use std::fmt; 4 3 5 - #[allow(dead_code, unused)] 6 - #[derive(Default)] 4 + #[derive(Debug)] 7 5 pub struct Set { 8 - id: String, 6 + pub id: String, 9 7 pub weight: Option<f32>, 10 8 pub reps: u32, 11 9 pub rpe: Option<f32>, 12 10 } 13 11 14 - impl fmt::Debug for Set { 15 - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 16 - f.debug_struct("Set") 17 - .field("weight", &self.weight) 18 - .field("reps", &self.reps) 19 - .field("rpe", &self.rpe) 20 - .finish() 21 - } 22 - } 23 - 24 - #[allow(dead_code, unused)] 25 12 #[derive(Debug)] 26 13 pub struct Exercise { 27 - id: String, 14 + pub id: String, 28 15 pub name: String, 29 16 pub sets: Vec<Set>, 30 17 } 31 18 32 - #[allow(dead_code, unused)] 33 19 #[derive(Debug)] 34 20 pub struct Workout { 35 21 pub id: String, ··· 131 117 132 118 let mut name = String::new(); 133 119 let workout_id = DataTransformer::get_workout_id_from_link(&cell_set_group.links); 134 - // get workout name from measurements 120 + // get workout name from measurements if available 135 121 if let Some(measurement) = lookup.get(&workout_id) { 136 122 name = (measurement.name).to_string(); 137 123 }
-1
strong-api-lib/src/json_response.rs
··· 1 1 use serde::{Deserialize, Serialize}; 2 2 use serde_json::Value; 3 3 4 - #[allow(dead_code, unused)] 5 4 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 6 5 pub struct UserResponse { 7 6 #[serde(rename = "_links")]
+1 -1
strong-api-lib/src/lib.rs
··· 1 1 pub mod data_transformer; 2 2 pub mod json_response; 3 - pub mod strong_api; 3 + pub mod strong_api;
-1
strong-api-lib/src/strong_api.rs
··· 42 42 user_id: Option<String>, 43 43 } 44 44 45 - #[allow(dead_code)] 46 45 #[derive(Debug)] 47 46 pub enum Includes { 48 47 Log,