Skip to content

Commit 6d52897

Browse files
authored
Merge pull request #1267 from rylev/fix-get-error
Fix `get_error` query
2 parents 86bb871 + 6b56221 commit 6d52897

File tree

7 files changed

+19
-48
lines changed

7 files changed

+19
-48
lines changed

database/src/pool.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ pub trait Connection: Send + Sync {
104104
series: u32,
105105
artifact_row_id: ArtifactIdNumber,
106106
) -> Option<QueryDatum>;
107-
async fn get_error(&self, artifact_row_id: ArtifactIdNumber)
108-
-> HashMap<String, Option<String>>;
107+
async fn get_error(&self, artifact_row_id: ArtifactIdNumber) -> HashMap<String, String>;
109108

110109
async fn queue_pr(
111110
&self,

database/src/pool/postgres.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl PostgresConnection {
430430
.await
431431
.unwrap(),
432432
get_error: conn.prepare("select crate, error from error_series
433-
left join error on error.series = error_series.id and aid = $1").await.unwrap(),
433+
inner join error on error.series = error_series.id and aid = $1").await.unwrap(),
434434
select_self_query_series: conn.prepare("select id from self_profile_query_series where crate = $1 and profile = $2 and cache = $3 and query = $4").await.unwrap(),
435435
insert_self_query_series: conn.prepare("insert into self_profile_query_series (crate, profile, cache, query) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING RETURNING id").await.unwrap(),
436436
insert_pstat_series: conn.prepare("insert into pstat_series (crate, profile, cache, statistic) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING RETURNING id").await.unwrap(),
@@ -703,10 +703,7 @@ where
703703
})
704704
.collect()
705705
}
706-
async fn get_error(
707-
&self,
708-
artifact_row_id: crate::ArtifactIdNumber,
709-
) -> HashMap<String, Option<String>> {
706+
async fn get_error(&self, artifact_row_id: crate::ArtifactIdNumber) -> HashMap<String, String> {
710707
let rows = self
711708
.conn()
712709
.query(&self.statements().get_error, &[&(artifact_row_id.0 as i32)])

database/src/pool/sqlite.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,11 @@ impl Connection for SqliteConnection {
620620
.collect::<Result<_, _>>()
621621
.unwrap()
622622
}
623-
async fn get_error(&self, aid: crate::ArtifactIdNumber) -> HashMap<String, Option<String>> {
623+
async fn get_error(&self, aid: crate::ArtifactIdNumber) -> HashMap<String, String> {
624624
self.raw_ref()
625625
.prepare_cached(
626626
"select crate, error from error_series
627-
left join error on error.series = error_series.id and aid = ?",
627+
inner join error on error.series = error_series.id and aid = ?",
628628
)
629629
.unwrap()
630630
.query_map(params![&aid.0], |row| Ok((row.get(0)?, row.get(1)?)))

site/src/api.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ pub mod status {
206206
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
207207
pub struct BenchmarkStatus {
208208
pub name: String,
209-
pub success: bool,
210-
pub error: Option<String>,
209+
pub error: String,
211210
}
212211

213212
#[derive(Serialize, Debug)]

site/src/comparison.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -622,21 +622,17 @@ async fn compare_given_commits(
622622
})
623623
.collect();
624624

625-
let mut errors = conn.get_error(b.lookup(&idx).unwrap()).await;
626-
for (name, error) in conn.get_error(a.lookup(&idx).unwrap()).await {
627-
if error.is_some() {
628-
errors.remove(&name);
629-
}
625+
let mut errors_in_b = conn.get_error(b.lookup(&idx).unwrap()).await;
626+
let errors_in_a = conn.get_error(a.lookup(&idx).unwrap()).await;
627+
for (name, _) in errors_in_a {
628+
errors_in_b.remove(&name);
630629
}
631630

632631
Ok(Some(Comparison {
633632
a: ArtifactDescription::for_artifact(&*conn, a.clone(), master_commits).await,
634633
b: ArtifactDescription::for_artifact(&*conn, b.clone(), master_commits).await,
635634
statistics,
636-
new_errors: errors
637-
.into_iter()
638-
.filter_map(|(k, v)| v.map(|v| (k, v)))
639-
.collect(),
635+
new_errors: errors_in_b.into_iter().collect(),
640636
}))
641637
}
642638

site/src/request_handlers/status_page.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,14 @@ pub async fn handle_status_page(ctxt: Arc<SiteCtxt>) -> status::Response {
4141
} else {
4242
Default::default()
4343
};
44-
let mut benchmark_state = errors
44+
let benchmark_state = errors
4545
.into_iter()
4646
.map(|(name, error)| {
47-
let msg = if let Some(error) = error {
48-
Some(prettify_log(&error).unwrap_or(error))
49-
} else {
50-
None
51-
};
52-
status::BenchmarkStatus {
53-
name,
54-
success: msg.is_none(),
55-
error: msg,
56-
}
47+
let error = prettify_log(&error).unwrap_or(error);
48+
status::BenchmarkStatus { name, error }
5749
})
5850
.collect::<Vec<_>>();
5951

60-
benchmark_state.sort_by_key(|s| s.error.is_some());
61-
benchmark_state.reverse();
62-
6352
status::Response {
6453
last_commit,
6554
benchmarks: benchmark_state,

site/static/status.html

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</div>
2828
<div id="data">
2929
<div id="data-insert-js"></div>
30-
Benchmarks for last commit:
30+
Benchmarking errors for last commit:
3131
<div id="benchmark-state"></div>
3232
</div>
3333
<div id="as-of"></div>
@@ -46,19 +46,11 @@
4646
}
4747
for (let benchmark of data.benchmarks) {
4848
let element = document.createElement("div");
49-
if (benchmark.error) {
50-
element.innerHTML = `<details open>
49+
element.innerHTML = `<details open>
5150
<summary>${benchmark.name} - error</summary>
5251
<pre class="benchmark-error"></pre>
5352
</details>`;
54-
} else {
55-
element.innerHTML = `
56-
<p style="margin:0.1em;">${benchmark.name} - successful</p>
57-
`;
58-
}
59-
if (benchmark.error) {
60-
element.querySelector(".benchmark-error").innerText = benchmark.error;
61-
}
53+
element.querySelector(".benchmark-error").innerText = benchmark.error;
6254
state_div.appendChild(element);
6355
}
6456
let missing_div = document.querySelector("#data-insert-js");
@@ -175,8 +167,7 @@
175167
return `${reason_to_string(reason.InProgress)} - in progress`;
176168
} else if (reason["Master"] != undefined && reason.Master.pr) {
177169
return `<a href="https://github.com/rust-lang/rust/pull/${reason["Master"].pr}">
178-
#${reason["Master"].pr}</a>${
179-
reason.Master.is_try_parent ? " - Try commit parent" : ""
170+
#${reason["Master"].pr}</a>${reason.Master.is_try_parent ? " - Try commit parent" : ""
180171
}`;
181172
} else if (reason["Master"] != undefined && reason.Master.pr == 0) {
182173
return "Master";
@@ -227,4 +218,4 @@
227218
</script>
228219
</body>
229220

230-
</html>
221+
</html>

0 commit comments

Comments
 (0)