History

[hours-demo] deduplication is enabled by default

Sebastian Thiel committed 5 years ago

Commit cede3271 parent 4b87deb1 file · +12 −12Browse files

Unified · Split

examples/hours/src/main.rs+12−12
@@ -51,9 +51,9 @@ struct Opts { · 50 unmodified lines
5151 /// Omit personally identifiable information, leaving only the summary.
5252 #[clap(short = 'p', long)]
5353 omit_pii: bool,
54− /// Unify identities by name and email.
54+ /// Omit unifying identities by name and email.
5555 #[clap(short = 'i', long)]
56− unify_identities: bool,
56+ omit_unify_identities: bool,
5757 }
5858
5959 fn main() -> anyhow::Result<()> {
@@ -146,13 +146,13 @@ fn main() -> anyhow::Result<()> { · 86 unmodified lines
146146 results_by_hours.push(estimate_hours(commits));
147147 }
148148
149− let num_contributors = results_by_hours.len();
150− let mut results_by_hours = if opts.unify_identities {
149+ let num_authors = results_by_hours.len();
150+ let mut results_by_hours = if !opts.omit_unify_identities {
151151 let start = Instant::now();
152152 let res = deduplicate_identities(&results_by_hours);
153153 let elapsed = start.elapsed();
154154 eprintln!(
155− "Deduplicated {} contributors in {:.02}s by name and email, now {}",
155+ "Deduplicated {} authors in {:.02}s by name and email, now {}",
156156 results_by_hours.len(),
157157 elapsed.as_secs_f32(),
158158 res.len()
@@ -166,7 +166,7 @@ fn main() -> anyhow::Result<()> { · 7 unmodified lines
166166 acc
167167 })
168168 };
169− let num_unique_contributors = results_by_hours.len();
169+ let num_unique_authors = results_by_hours.len();
170170 if !opts.omit_pii {
171171 results_by_hours.sort_by(|a, b| a.hours.partial_cmp(&b.hours).unwrap_or(std::cmp::Ordering::Equal));
172172 let stdout = io::stdout();
@@ -182,18 +182,18 @@ fn main() -> anyhow::Result<()> { · 9 unmodified lines
182182 .expect("at least one commit at this point");
183183 writeln!(
184184 io::stdout(),
185− "total hours: {:.02}\ntotal 8h days: {:.02}\ntotal commits = {}\ntotal contributors: {}",
185+ "total hours: {:.02}\ntotal 8h days: {:.02}\ntotal commits = {}\ntotal authors: {}",
186186 total_hours,
187187 total_hours / HOURS_PER_WORKDAY,
188188 total_commits,
189− num_contributors
189+ num_authors
190190 )?;
191− if opts.unify_identities {
191+ if !opts.omit_unify_identities {
192192 writeln!(
193193 io::stdout(),
194− "total unique contributors: {} ({:.02}% duplication)",
195− num_unique_contributors,
196− (1.0 - (num_unique_contributors as f32 / num_contributors as f32)) * 100.0
194+ "total unique authors: {} ({:.02}% duplication)",
195+ num_unique_authors,
196+ (1.0 - (num_unique_authors as f32 / num_authors as f32)) * 100.0
197197 )?;
198198 }
199199 assert_eq!(total_commits, all_commits.len() as u32, "need to get all commits");