diff --git a/.gitignore b/.gitignore index 4d42116..20fca09 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ target/ .DS_Store *.svg !assets/*.svg -pkg/ \ No newline at end of file +pkg/ diff --git a/Cargo.lock b/Cargo.lock index 8667c09..fba1a40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -342,7 +342,7 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "githubchart-rust" -version = "5.1.3" +version = "5.1.4" dependencies = [ "getrandom", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 5d32994..4129fb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "githubchart-rust" -version = "5.1.3" +version = "5.1.4" authors = ["frytg"] edition = "2021" license = "MIT" diff --git a/README.md b/README.md index 6da52d5..a431f7e 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Use `cargo fmt` to format the code and `cargo test` to run the tests. Alternatively, you can download a release binary from the [releases page](https://github.com/frytg/githubchart-rust/releases) and run it directly: ```sh -./githubchart output.svg -u frytg +./githubchart-rust output.svg -u frytg ``` ## Build @@ -43,7 +43,7 @@ cargo build --release Test the binary with: ```sh -./target/release/githubchart release.svg -u frytg +./target/release/githubchart-rust release.svg -u frytg ``` ## Build for Web diff --git a/src/lib.rs b/src/lib.rs index 1ab8e81..478e0dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,11 +26,11 @@ impl Chart { pub const COLOR_SCHEMES: &[(&str, &[&str])] = &[ ( "default", - &["#eeeeee", "#c6e48b", "#7bc96f", "#239a3b", "#196127"], + &["#F0F3F8", "#9CE2A8", "#39C651", "#339944", "#20602A"], ), ( - "old", - &["#eeeeee", "#d6e685", "#8cc665", "#44a340", "#1e6823"], + "dark", + &["#191C1F", "#0A431D", "#0D5926", "#1AB34D", "#2BE168"], ), ( "halloween", @@ -89,11 +89,14 @@ pub async fn fetch_github_stats( mod tests; #[wasm_bindgen] -pub async fn generate_github_chart(username: &str, color_scheme: Option) -> Result { +pub async fn generate_github_chart( + username: &str, + color_scheme: Option, +) -> Result { let stats = fetch_github_stats(username) .await .map_err(|e| JsValue::from_str(&e.to_string()))?; - + let colors = match color_scheme.as_deref() { Some(scheme) => COLOR_SCHEMES .iter() diff --git a/src/svg.rs b/src/svg.rs index 35e9d25..466cd9c 100644 --- a/src/svg.rs +++ b/src/svg.rs @@ -42,11 +42,11 @@ struct Point { fn svg_add_points(grid: &[Vec], svg: &mut String, colors: &[&str]) { for (x, row) in grid.iter().enumerate() { for (y, point) in row.iter().enumerate() { - if point.score == -1 { + if point.score == -1 || !point.date.contains("-") { continue; } svg.push_str(&format!( - r#""#, + r#""#, (x * CUBE_SIZE) + X_PAD, (y * CUBE_SIZE) + Y_PAD, point_color(point.score, colors), @@ -105,9 +105,9 @@ fn svg_add_months(svg: &mut String, stats: &[(String, i32)]) { fn point_color<'a>(score: i32, colors: &'a [&str]) -> &'a str { let index = match score { 0 => 0, - 1..=3 => 1, - 4..=6 => 2, - 7..=9 => 3, + 1 => 1, + 2 => 2, + 3 => 3, _ => 4, }; colors.get(index).unwrap_or(&colors[0]) diff --git a/src/tests.rs b/src/tests.rs index aa92fa6..9f5bfef 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -55,7 +55,7 @@ mod tests { assert_eq!(COLOR_SCHEMES[0].1.len(), 5); // Test old scheme - assert_eq!(COLOR_SCHEMES[1].0, "old"); + assert_eq!(COLOR_SCHEMES[1].0, "dark"); assert_eq!(COLOR_SCHEMES[1].1.len(), 5); // Test halloween scheme diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 33a9f4d..1e8cde4 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1,5 +1,5 @@ -use regex::Regex; use githubchart_rust::{fetch_github_stats, Chart, COLOR_SCHEMES}; +use regex::Regex; #[tokio::test] async fn test_github_stats_fetching() {