diff --git a/CHANGELOG.md b/CHANGELOG.md index e89bb40..c8585f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,3 +30,6 @@ * bump rodio to v0.12 + move some functions around to get it working * fix tinytemplate default file shenanigans * removed italics within the tag counter + +## 1.1.3 +* changed tagweight table to use percentages instead of floats diff --git a/Cargo.toml b/Cargo.toml index dc8e5e4..8e60cad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rusty-krab-manager" -version = "1.1.2" +version = "1.1.3" authors = ["luak "] edition = "2018" readme = "README.md" diff --git a/src/assignment_utils.rs b/src/assignment_utils.rs index 96bf98e..2615ef6 100644 --- a/src/assignment_utils.rs +++ b/src/assignment_utils.rs @@ -183,13 +183,23 @@ pub fn create_weighttable( let curr_assign = &assign_vec[i]; new.push(curr_assign.tag.clone()); new.push(curr_assign.name.clone()); - new.push(format!("{:.4}", tag_weights[i_tags])); - new.push(format!("{:.4}", assign_pdf[i])); - new.push(format!("{:.4}", (assign_pdf[i] * tag_weights[i_tags]))); + new.push(format!("{:.2}%", tag_weights[i_tags] * 100.0)); + new.push(format!("{:.2}%", assign_pdf[i] * 100.0)); + new.push(format!( + "{:.2}%", + (assign_pdf[i] * tag_weights[i_tags] * 100.0) + )); toret.push(new); } } - toret.sort_by(|a, b| b[4].cmp(&a[4])); + // following code to sort by percentage values + toret.sort_by(|a, b| { + b[4][..b[4].find("%").unwrap()] + .parse::() + .unwrap() + .partial_cmp(&a[4][..a[4].find("%").unwrap()].parse::().unwrap()) + .unwrap() + }); return toret; }