Skip to content

Commit 4667451

Browse files
committed
Support VirtualRide
1 parent c1f0dbb commit 4667451

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/component/splits.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,9 @@ pub fn draw(
3838
constraints.push(Constraint::Max(0));
3939

4040
let mut rows = vec![];
41-
let sport_type = match activity.sport_type.as_str() {
42-
"Ride" => SportType::Ride,
43-
_ => SportType::Run,
44-
};
45-
let speed_header = match sport_type {
41+
let speed_header = match activity.activity_category() {
4642
SportType::Ride => "󰓅 Speed",
47-
SportType::Run => "👣 Pace",
43+
_ => "👣 Pace",
4844
};
4945
let header = vec![
5046
"#",
@@ -64,7 +60,7 @@ pub fn draw(
6460
rows.push(
6561
Row::new([
6662
Cell::from(format!("{}", count)).set_style(Style::default().bg(color)),
67-
match sport_type {
63+
match activity.activity_category() {
6864
SportType::Ride => Cell::from(
6965
app.unit_formatter.speed(split.meters_per_hour()),
7066
),

src/component/stats.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub fn draw(
2222
}
2323
),
2424
),
25+
("Activity Type".to_string(), format!("{}", activity.activity_type)),
26+
("Sport Type".to_string(), format!("{}", activity.sport_type)),
2527
("Kudos".to_string(), format!("{}", activity.kudos)),
2628
(
2729
"Split".to_string(),

src/store/activity.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub enum SortBy {
2525
pub enum SportType {
2626
Ride,
2727
Run,
28+
Unknown,
2829
}
2930

3031
impl Display for SortBy {
@@ -448,9 +449,21 @@ impl Activity {
448449
self.distance / (self.moving_time as f64 / 3600.0)
449450
}
450451

452+
pub fn activity_category(&self) -> SportType {
453+
match self.activity_type.as_str() {
454+
"Ride" => SportType::Ride,
455+
"VirtualRide" => SportType::Ride,
456+
"Run" => SportType::Run,
457+
"VirtualRun" => SportType::Run,
458+
"TrailRun" => SportType::Run,
459+
_ => SportType::Unknown,
460+
}
461+
}
462+
451463
pub fn activity_type_icon(&self) -> String {
452464
match self.activity_type.as_str() {
453465
"Ride" => "🚴".to_string(),
466+
"VirtualRide" => "💻🚴".to_string(),
454467
"Run" => "🏃".to_string(),
455468
"TrailRun" => "🏃".to_string(),
456469
"Walk" => "🥾".to_string(),

0 commit comments

Comments
 (0)