-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read build-status and rustc-version directly from builds instead of release #2267
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,7 +117,7 @@ impl CrateDetails { | |
releases.readme, | ||
releases.description_long, | ||
releases.release_time, | ||
releases.build_status, | ||
COALESCE(builds.build_status, false) as build_status, | ||
releases.rustdoc_status, | ||
releases.archive_storage, | ||
releases.repository_url, | ||
|
@@ -136,7 +136,7 @@ impl CrateDetails { | |
releases.license, | ||
releases.documentation_url, | ||
releases.default_target, | ||
releases.doc_rustc_version, | ||
builds.rustc_version, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should already either remove or just rename the now unused columns. This would also surface places which we might have forgotten. |
||
doc_coverage.total_items, | ||
doc_coverage.documented_items, | ||
doc_coverage.total_items_needing_examples, | ||
|
@@ -145,6 +145,12 @@ impl CrateDetails { | |
INNER JOIN crates ON releases.crate_id = crates.id | ||
LEFT JOIN doc_coverage ON doc_coverage.release_id = releases.id | ||
LEFT JOIN repositories ON releases.repository_id = repositories.id | ||
LEFT JOIN LATERAL ( | ||
SELECT * FROM builds | ||
WHERE builds.rid = releases.id | ||
ORDER BY builds.build_time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the |
||
DESC LIMIT 1 | ||
) AS builds ON true | ||
WHERE crates.name = $1 AND releases.version = $2;"; | ||
|
||
let rows = conn.query(query, &[&name, &version])?; | ||
|
@@ -182,7 +188,10 @@ impl CrateDetails { | |
default_target: krate.get("default_target"), | ||
doc_targets: MetaData::parse_doc_targets(krate.get("doc_targets")), | ||
yanked: krate.get("yanked"), | ||
rustdoc_css_file: get_correct_docsrs_style_file(krate.get("doc_rustc_version"))?, | ||
rustdoc_css_file: krate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. related question: Wouldn't this change not break old docs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If so that was before my time, would have to check the prod database dump |
||
.get::<_, Option<&str>>("rustc_version") | ||
.map(get_correct_docsrs_style_file) | ||
.transpose()?, | ||
}; | ||
|
||
let mut crate_details = CrateDetails { | ||
|
@@ -305,14 +314,20 @@ pub(crate) fn releases_for_crate( | |
let mut releases: Vec<Release> = conn | ||
.query( | ||
"SELECT | ||
id, | ||
version, | ||
build_status, | ||
yanked, | ||
is_library, | ||
rustdoc_status, | ||
target_name | ||
releases.id, | ||
releases.version, | ||
COALESCE(builds.build_status, false) as build_status, | ||
releases.yanked, | ||
releases.is_library, | ||
releases.rustdoc_status, | ||
releases.target_name | ||
FROM releases | ||
LEFT JOIN LATERAL ( | ||
SELECT build_status FROM builds | ||
WHERE builds.rid = releases.id | ||
ORDER BY builds.build_time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the |
||
DESC LIMIT 1 | ||
) AS builds ON true | ||
WHERE | ||
releases.crate_id = $1", | ||
&[&crate_id], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -509,44 +509,54 @@ pub(crate) struct MetaData { | |
pub(crate) yanked: bool, | ||
/// CSS file to use depending on the rustdoc version used to generate this version of this | ||
/// crate. | ||
pub(crate) rustdoc_css_file: String, | ||
pub(crate) rustdoc_css_file: Option<String>, | ||
} | ||
|
||
impl MetaData { | ||
#[fn_error_context::context("getting metadata for {name} {version}")] | ||
fn from_crate( | ||
conn: &mut Client, | ||
name: &str, | ||
version: &str, | ||
version_or_latest: &str, | ||
) -> Result<MetaData> { | ||
conn.query_opt( | ||
"SELECT crates.name, | ||
releases.version, | ||
releases.description, | ||
releases.target_name, | ||
releases.rustdoc_status, | ||
releases.default_target, | ||
releases.doc_targets, | ||
releases.yanked, | ||
releases.doc_rustc_version | ||
FROM releases | ||
INNER JOIN crates ON crates.id = releases.crate_id | ||
WHERE crates.name = $1 AND releases.version = $2", | ||
let row = conn.query_one( | ||
"SELECT | ||
crates.name, | ||
releases.version, | ||
releases.description, | ||
releases.target_name, | ||
releases.rustdoc_status, | ||
releases.default_target, | ||
releases.doc_targets, | ||
releases.yanked, | ||
builds.rustc_version | ||
FROM releases | ||
INNER JOIN crates ON crates.id = releases.crate_id | ||
LEFT JOIN LATERAL ( | ||
SELECT * FROM builds | ||
WHERE builds.rid = releases.id | ||
ORDER BY builds.build_time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the |
||
DESC LIMIT 1 | ||
) AS builds ON true | ||
WHERE crates.name = $1 AND releases.version = $2", | ||
&[&name, &version], | ||
)? | ||
.map(|row| MetaData { | ||
name: row.get(0), | ||
version: row.get(1), | ||
)?; | ||
Ok(MetaData { | ||
name: row.get("name"), | ||
version: row.get("version"), | ||
version_or_latest: version_or_latest.to_string(), | ||
description: row.get(2), | ||
target_name: row.get(3), | ||
rustdoc_status: row.get(4), | ||
default_target: row.get(5), | ||
doc_targets: MetaData::parse_doc_targets(row.get(6)), | ||
yanked: row.get(7), | ||
rustdoc_css_file: get_correct_docsrs_style_file(row.get(8)).unwrap(), | ||
description: row.get("description"), | ||
target_name: row.get("target_name"), | ||
rustdoc_status: row.get("rustdoc_status"), | ||
default_target: row.get("default_target"), | ||
doc_targets: MetaData::parse_doc_targets(row.get("doc_targets")), | ||
yanked: row.get("yanked"), | ||
rustdoc_css_file: row | ||
.get::<_, Option<&str>>("rustc_version") | ||
.map(get_correct_docsrs_style_file) | ||
.transpose()?, | ||
}) | ||
.ok_or_else(|| anyhow!("missing metadata for {} {}", name, version)) | ||
} | ||
|
||
fn parse_doc_targets(targets: Value) -> Vec<String> { | ||
|
@@ -938,7 +948,7 @@ mod test { | |
"arm64-unknown-linux-gnu".to_string(), | ||
], | ||
yanked: false, | ||
rustdoc_css_file: "rustdoc.css".to_string(), | ||
rustdoc_css_file: Some("rustdoc.css".to_string()), | ||
}; | ||
|
||
let correct_json = json!({ | ||
|
@@ -1016,7 +1026,7 @@ mod test { | |
default_target: "x86_64-unknown-linux-gnu".to_string(), | ||
doc_targets: vec![], | ||
yanked: false, | ||
rustdoc_css_file: "rustdoc.css".to_string(), | ||
rustdoc_css_file: Some("rustdoc.css".to_string()), | ||
}, | ||
); | ||
Ok(()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,7 @@ pub(crate) fn get_releases( | |
INNER JOIN builds ON releases.id = builds.rid | ||
LEFT JOIN repositories ON releases.repository_id = repositories.id | ||
WHERE | ||
((NOT $3) OR (releases.build_status = FALSE AND releases.is_library = TRUE)) | ||
((NOT $3) OR (builds.build_status = FALSE AND releases.is_library = TRUE)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps I'm missing something, but this would change behaviour of the query, for the case when we have multiple builds for a release.
So assuming that the last build was successful, and the first one broke, in the old query we wouldn't see that release in the result, because the last build succeeded. In the new query we would see the release in the result because an older build failed, while the most recent one passed. |
||
AND {0} IS NOT NULL | ||
|
||
ORDER BY {0} DESC | ||
|
@@ -658,7 +658,7 @@ pub(crate) async fn activity_handler( | |
SELECT | ||
release_time::date AS date_, | ||
COUNT(*) AS counts, | ||
SUM(CAST((is_library = TRUE AND build_status = FALSE) AS INT)) AS failures | ||
SUM(CAST((is_library = TRUE AND (SELECT builds.build_status FROM builds WHERE builds.rid = releases.id ORDER BY builds.build_time DESC LIMIT 1) = FALSE) AS INT)) AS failures | ||
FROM | ||
releases | ||
WHERE | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should already either remove or just rename the now unused columns.
This would also surface places which we might have forgotten.