diff options
author | Daniel Schadt <kingdread@gmx.de> | 2020-06-26 17:00:58 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2020-06-26 17:00:58 +0200 |
commit | e9c4f208a696cb6e6eaaf0c9595672b00d301e13 (patch) | |
tree | ad6a5c4653646e05521493fc46d8e2b241b670ef | |
parent | 86e0f74bd7f0301886c1dda0f147b6c8ffbdd707 (diff) | |
download | raidgrep-e9c4f208a696cb6e6eaaf0c9595672b00d301e13.tar.gz raidgrep-e9c4f208a696cb6e6eaaf0c9595672b00d301e13.tar.bz2 raidgrep-e9c4f208a696cb6e6eaaf0c9595672b00d301e13.zip |
implement sorting based on duration
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/output/sorting.rs | 9 |
2 files changed, 8 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b2b15a3..9822318 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ### Added - The `--check` command line argument to check a single file. - Comparison based filters (`count`, `-time`, `-duration`). +- Sorting based on fight duration. ### Changed - The exit code will now be dependent on whether logs matching the filter were diff --git a/src/output/sorting.rs b/src/output/sorting.rs index 78f3538..2a0821c 100644 --- a/src/output/sorting.rs +++ b/src/output/sorting.rs @@ -29,6 +29,8 @@ pub enum Component { Outcome, /// Sort based on whether the Challenge Mote was active or not. ChallengeMote, + /// Sort based on the fight duration. + Duration, /// Sort by the given component but in reverse direction. Reverse(Box<Component>), @@ -46,6 +48,7 @@ impl FromStr for Component { "boss" => Ok(Component::Boss), "outcome" => Ok(Component::Outcome), "cm" => Ok(Component::ChallengeMote), + "duration" => Ok(Component::Duration), _ => Err(InvalidComponent), } } @@ -58,6 +61,7 @@ impl Display for Component { Component::Boss => write!(f, "boss"), Component::Outcome => write!(f, "outcome"), Component::ChallengeMote => write!(f, "cm"), + Component::Duration => write!(f, "duration"), Component::Reverse(ref inner) => write!(f, "~{}", inner), } } @@ -74,6 +78,7 @@ impl Component { Component::Boss => boss_id(lhs).cmp(&boss_id(rhs)), Component::Outcome => lhs.outcome.cmp(&rhs.outcome), Component::ChallengeMote => lhs.is_cm.cmp(&rhs.is_cm), + Component::Duration => lhs.duration.cmp(&rhs.duration), Component::Reverse(ref inner) => inner.cmp(lhs, rhs).reverse(), } } @@ -130,7 +135,6 @@ mod tests { use super::*; use chrono::prelude::*; - use chrono::Duration; use evtclib::Boss as B; #[test] @@ -139,6 +143,7 @@ mod tests { assert_eq!("boss".parse(), Ok(Component::Boss)); assert_eq!("outcome".parse(), Ok(Component::Outcome)); assert_eq!("cm".parse(), Ok(Component::ChallengeMote)); + assert_eq!("duration".parse(), Ok(Component::Duration)); assert_eq!("foobar".parse::<Component>(), Err(InvalidComponent)); @@ -164,7 +169,7 @@ mod tests { fn test_sorting_cmp() { use Component::*; - let duration = Duration::zero(); + let duration = chrono::Duration::zero(); let logs: &[&LogResult] = &[ &LogResult { log_file: "".into(), |