Skip to content

Commit a89aa16

Browse files
committed
Make triage reporting a bit more efficient
1 parent 73783d9 commit a89aa16

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

site/src/comparison.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,22 @@ pub async fn handle_triage(
2424
) -> Result<api::triage::Response, BoxedError> {
2525
let start = body.start;
2626
let end = body.end;
27-
// Compare against self to get next
2827
let master_commits = collector::master_commits().await?;
29-
let comparison = compare_given_commits(
30-
start.clone(),
31-
start.clone(),
32-
"instructions:u".to_owned(),
33-
ctxt,
34-
&master_commits,
35-
)
36-
.await?
37-
.unwrap();
38-
let mut after = Bound::Commit(comparison.next(&master_commits).unwrap()); // TODO: handle no next commit
28+
29+
let start_artifact = ctxt
30+
.artifact_id_for_bound(start.clone(), true)
31+
.ok_or(format!("could not find start commit for bound {:?}", start))?;
32+
let mut next = next_commit(&start_artifact, &master_commits)
33+
.map(|c| Bound::Commit(c.sha.clone()))
34+
.unwrap(); // TODO: handle no next commit
3935

4036
let mut report = HashMap::new();
4137
let mut before = start.clone();
4238

4339
loop {
4440
let comparison = match compare_given_commits(
4541
before,
46-
after.clone(),
42+
next.clone(),
4743
"instructions:u".to_owned(),
4844
ctxt,
4945
&master_commits,
@@ -54,7 +50,7 @@ pub async fn handle_triage(
5450
None => {
5551
log::info!(
5652
"No data found for end bound {:?}. Ending comparison...",
57-
after
53+
next
5854
);
5955
break;
6056
}
@@ -71,14 +67,14 @@ pub async fn handle_triage(
7167
// Check that there is a next commit and that the
7268
// after commit is not equal to `end`
7369
match comparison.next(&master_commits).map(Bound::Commit) {
74-
Some(next) if Some(&after) != end.as_ref() => {
75-
before = after;
76-
after = next;
70+
Some(n) if Some(&next) != end.as_ref() => {
71+
before = next;
72+
next = n;
7773
}
7874
_ => break,
7975
}
8076
}
81-
let end = end.unwrap_or(after);
77+
let end = end.unwrap_or(next);
8278

8379
let report = generate_report(&start, &end, report);
8480
Ok(api::triage::Response(report))

0 commit comments

Comments
 (0)