Skip to content

Commit d667e59

Browse files
committed
Add helper to index
1 parent ddb33b1 commit d667e59

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

database/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,18 @@ impl Index {
690690
) -> impl Iterator<Item = &'_ (Benchmark, Profile, Scenario, Metric)> + '_ {
691691
self.pstat_series.map.keys()
692692
}
693+
694+
pub fn artifact_id_for_commit(&self, commit: &str) -> Option<ArtifactId> {
695+
self.commits()
696+
.into_iter()
697+
.find(|c| c.sha == *commit)
698+
.map(|c| ArtifactId::Commit(c))
699+
.or_else(|| {
700+
self.artifacts()
701+
.find(|a| *a == commit)
702+
.map(|a| ArtifactId::Tag(a.to_owned()))
703+
})
704+
}
693705
}
694706

695707
#[derive(Debug)]

site/src/request_handlers/self_profile.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -595,17 +595,8 @@ pub async fn handle_self_profile(
595595
// Helper for finding an `ArtifactId` based on a commit sha
596596
let find_aid = |commit: &str| {
597597
index
598-
.commits()
599-
.into_iter()
600-
.find(|c| c.sha == *commit)
601-
.map(|c| ArtifactId::Commit(c))
602-
.or_else(|| {
603-
index
604-
.artifacts()
605-
.find(|a| *a == commit)
606-
.map(|a| ArtifactId::Tag(a.to_owned()))
607-
})
608-
.ok_or(format!("could not find artifact {}", body.commit))
598+
.artifact_id_for_commit(commit)
599+
.ok_or(format!("could not find artifact {}", commit))
609600
};
610601

611602
let mut commits = vec![find_aid(&body.commit)?];

0 commit comments

Comments
 (0)