Skip to content

Commit 827799d

Browse files
committed
updates
1 parent a34da19 commit 827799d

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/diff.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub struct DifferenceReport {
99
pub sections: Vec<ReportItemDifference>,
1010
}
1111

12+
// TODO: get rid of this and just return DiffSummary
1213
#[derive(Debug, Serialize, Clone)]
1314
pub struct ReportItemDifference {
1415
pub unit_name: String,

src/pr.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
use crate::diff::{DifferenceReport, ReportItemDifference};
22

3+
/***
4+
*
5+
*
6+
*
7+
*
8+
* HEY
9+
*
10+
*
11+
*
12+
* THis whole file is hot garbage and I need to refactor it
13+
*
14+
* But we're just trying to get OK bot talking for now
15+
*/
16+
317
#[derive(Debug)]
418
pub struct DiffSummary {
519
pub unit_name: String,
620
pub name: String,
721
pub percent_difference: f32,
22+
pub size: u64,
823
pub size_difference: u64,
924
}
1025

@@ -18,21 +33,32 @@ impl DiffSummary {
1833
Some(demangled) => demangled.clone(),
1934
None => diff.name.clone(),
2035
},
36+
size: diff.size,
2137
percent_difference: percent_diff,
22-
size_difference: (((diff.size as f32) * percent_diff) as u64 / 4),
38+
size_difference: (((diff.size as f32) * (percent_diff / 100.0)) as u64),
2339
}
2440
}
2541

2642
pub fn to_string(&self) -> String {
2743
let direction = if self.percent_difference > 0.0 {
2844
"+"
2945
} else {
30-
"foo"
46+
"-"
47+
};
48+
println!("{:?}", self);
49+
let percent = format!("{:.2}%", self.percent_difference);
50+
51+
let emoji = match self.percent_difference {
52+
100.00 => "✅",
53+
_ => match self.percent_difference > 0.0 {
54+
true => "📈",
55+
false => "📉",
56+
},
3157
};
3258

3359
format!(
34-
"{}: {} ({direction}{})",
35-
self.name, self.percent_difference, self.size_difference
60+
"{emoji} `{}` - `{}`: {direction}{} ({direction}{})",
61+
self.unit_name, self.name, percent, self.size_difference
3662
)
3763
}
3864
}

0 commit comments

Comments
 (0)