aboutsummaryrefslogtreecommitdiff
path: root/src/output
diff options
context:
space:
mode:
Diffstat (limited to 'src/output')
-rw-r--r--src/output/sorting.rs9
1 files changed, 7 insertions, 2 deletions
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(),