Skip to content

Commit b9d2f26

Browse files
authored
Merge pull request #910 from rylev/more-efficient-triage
Make triage reporting a bit more efficient
2 parents 3acfb84 + a89aa16 commit b9d2f26

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
@@ -25,26 +25,22 @@ pub async fn handle_triage(
2525
) -> Result<api::triage::Response, BoxedError> {
2626
let start = body.start;
2727
let end = body.end;
28-
// Compare against self to get next
2928
let master_commits = collector::master_commits().await?;
30-
let comparison = compare_given_commits(
31-
start.clone(),
32-
start.clone(),
33-
"instructions:u".to_owned(),
34-
ctxt,
35-
&master_commits,
36-
)
37-
.await?
38-
.unwrap();
39-
let mut after = Bound::Commit(comparison.next(&master_commits).unwrap()); // TODO: handle no next commit
29+
30+
let start_artifact = ctxt
31+
.artifact_id_for_bound(start.clone(), true)
32+
.ok_or(format!("could not find start commit for bound {:?}", start))?;
33+
let mut next = next_commit(&start_artifact, &master_commits)
34+
.map(|c| Bound::Commit(c.sha.clone()))
35+
.unwrap(); // TODO: handle no next commit
4036

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

4440
loop {
4541
let comparison = match compare_given_commits(
4642
before,
47-
after.clone(),
43+
next.clone(),
4844
"instructions:u".to_owned(),
4945
ctxt,
5046
&master_commits,
@@ -55,7 +51,7 @@ pub async fn handle_triage(
5551
None => {
5652
log::info!(
5753
"No data found for end bound {:?}. Ending comparison...",
58-
after
54+
next
5955
);
6056
break;
6157
}
@@ -72,14 +68,14 @@ pub async fn handle_triage(
7268
// Check that there is a next commit and that the
7369
// after commit is not equal to `end`
7470
match comparison.next(&master_commits).map(Bound::Commit) {
75-
Some(next) if Some(&after) != end.as_ref() => {
76-
before = after;
77-
after = next;
71+
Some(n) if Some(&next) != end.as_ref() => {
72+
before = next;
73+
next = n;
7874
}
7975
_ => break,
8076
}
8177
}
82-
let end = end.unwrap_or(after);
78+
let end = end.unwrap_or(next);
8379

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

0 commit comments

Comments
 (0)