Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/bin/docs_rs_web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,3 @@ pretty_assertions = { workspace = true }
tempfile = { workspace = true }
test-case = { workspace = true }
walkdir = { workspace = true }

32 changes: 23 additions & 9 deletions crates/bin/docs_rs_web/src/handlers/builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use docs_rs_build_limits::Limits;
use docs_rs_build_queue::{AsyncBuildQueue, PRIORITY_MANUAL_FROM_CRATES_IO};
use docs_rs_context::Context;
use docs_rs_headers::CanonicalUrl;
use docs_rs_types::{BuildId, BuildStatus, KrateName, ReqVersion, Version};
use docs_rs_types::{BuildId, BuildStatus, Duration, KrateName, ReqVersion, Version};
use http::StatusCode;
use std::sync::Arc;

Expand All @@ -32,6 +32,7 @@ pub(crate) struct Build {
docsrs_version: Option<String>,
build_status: BuildStatus,
build_time: Option<DateTime<Utc>>,
build_duration: Option<Duration>,
errors: Option<String>,
}

Expand Down Expand Up @@ -195,6 +196,20 @@ async fn get_builds(
builds.docsrs_version,
builds.build_status as "build_status: BuildStatus",
COALESCE(builds.build_finished, builds.build_started) as build_time,
CASE
WHEN builds.build_started IS NULL
-- for old builds, `build_started` is empty.
THEN NULL
ELSE
CASE
-- for in-progress builds we show the duration until now
WHEN builds.build_status = 'in_progress' THEN (CURRENT_TIMESTAMP - builds.build_started)
-- there are broken builds where the status is `error`, and `build_finished` is NULL
WHEN builds.build_finished IS NULL THEN NULL
-- for finished builds we can show the full duration
ELSE (builds.build_finished - builds.build_started)
END
END AS "build_duration?: Duration",
builds.errors
FROM builds
INNER JOIN releases ON releases.id = builds.rid
Expand Down Expand Up @@ -241,7 +256,7 @@ mod tests {
let response = env
.web_app()
.await
.get("/crate/foo/0.1.0/builds")
.assert_success("/crate/foo/0.1.0/builds")
.await?
.error_for_status()?;
response.assert_cache_control(CachePolicy::NoCaching, env.config());
Expand All @@ -254,8 +269,7 @@ mod tests {
.collect();

assert_eq!(rows.len(), 1);
// third column contains build-start time, even when the rest is empty
assert_eq!(rows[0].chars().filter(|&c| c == '—').count(), 2);
assert_eq!(rows[0].chars().filter(|&c| c == '—').count(), 3);

Ok(())
});
Expand Down Expand Up @@ -530,14 +544,14 @@ mod tests {
};
Overrides::save(&mut conn, &FOO, limits).await?;

let page = kuchikiki::parse_html().one(
let page = kuchikiki::parse_html().one(dbg!(
env.web_app()
.await
.get(&format!("/crate/foo/{V1}/builds"))
.assert_success(&format!("/crate/foo/{V1}/builds"))
.await?
.text()
.await?,
);
.await?
));

let header = page.select(".about h4").unwrap().next().unwrap();
assert_eq!(header.text_contents(), "foo's sandbox limits");
Expand All @@ -550,7 +564,7 @@ mod tests {
let values: Vec<_> = values.iter().map(|v| &**v).collect();

assert!(values.contains(&"6.44 GB"));
assert!(values.contains(&"2 hours"));
assert!(values.contains(&"2h"));
assert!(values.contains(&"102.4 kB"));
assert!(values.contains(&"blocked"));
assert!(values.contains(&"1"));
Expand Down
Loading
Loading