Skip to content

Commit 9220b70

Browse files
committed
feat: create rebuild-queue and show it under the releases/queue page
1 parent 0b0c7c6 commit 9220b70

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

src/build_queue.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use std::sync::Arc;
1515
use tokio::runtime::Runtime;
1616
use tracing::{debug, error, info};
1717

18+
pub(crate) const REBUILD_PRIORITY: i32 = 20;
19+
1820
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize)]
1921
pub(crate) struct QueuedCrate {
2022
#[serde(skip)]

src/web/releases.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Releases web handlers
22
33
use crate::{
4-
build_queue::QueuedCrate,
4+
build_queue::{QueuedCrate, REBUILD_PRIORITY},
55
cdn, impl_axum_webpage,
66
utils::{report_error, retry_async},
77
web::{
@@ -782,16 +782,24 @@ pub(crate) async fn activity_handler(mut conn: DbConnection) -> AxumResult<impl
782782
struct BuildQueuePage {
783783
description: &'static str,
784784
queue: Vec<QueuedCrate>,
785+
rebuild_queue: Vec<QueuedCrate>,
785786
active_cdn_deployments: Vec<String>,
786787
in_progress_builds: Vec<(String, String)>,
787788
csp_nonce: String,
789+
expand_rebuild_queue: bool,
788790
}
789791

790792
impl_axum_webpage! { BuildQueuePage }
791793

794+
#[derive(Deserialize)]
795+
pub(crate) struct BuildQueueParams {
796+
expand: Option<String>,
797+
}
798+
792799
pub(crate) async fn build_queue_handler(
793800
Extension(build_queue): Extension<Arc<AsyncBuildQueue>>,
794801
mut conn: DbConnection,
802+
Query(params): Query<BuildQueueParams>,
795803
) -> AxumResult<impl IntoResponse> {
796804
let mut active_cdn_deployments: Vec<_> = cdn::queued_or_active_crate_invalidations(&mut conn)
797805
.await?
@@ -823,6 +831,7 @@ pub(crate) async fn build_queue_handler(
823831
.map(|rec| (rec.name, rec.version))
824832
.collect();
825833

834+
let mut rebuild_queue = Vec::new();
826835
let queue: Vec<QueuedCrate> = build_queue
827836
.queued_crates()
828837
.await?
@@ -834,10 +843,14 @@ pub(crate) async fn build_queue_handler(
834843
})
835844
})
836845
.map(|mut krate| {
837-
// The priority here is inverted: in the database if a crate has a higher priority it
838-
// will be built after everything else, which is counter-intuitive for people not
839-
// familiar with docs.rs's inner workings.
840-
krate.priority = -krate.priority;
846+
if krate.priority >= REBUILD_PRIORITY {
847+
rebuild_queue.push(krate.clone());
848+
} else {
849+
// The priority here is inverted: in the database if a crate has a higher priority it
850+
// will be built after everything else, which is counter-intuitive for people not
851+
// familiar with docs.rs's inner workings.
852+
krate.priority = -krate.priority;
853+
}
841854

842855
krate
843856
})
@@ -846,9 +859,11 @@ pub(crate) async fn build_queue_handler(
846859
Ok(BuildQueuePage {
847860
description: "crate documentation scheduled to build & deploy",
848861
queue,
862+
rebuild_queue,
849863
active_cdn_deployments,
850864
in_progress_builds,
851865
csp_nonce: String::new(),
866+
expand_rebuild_queue: params.expand.is_some(),
852867
})
853868
}
854869

templates/releases/build_queue.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,37 @@
8787
<strong>There is nothing in the queue</strong>
8888
{%- endif %}
8989
</ol>
90+
91+
<div class="release">
92+
<strong>Rebuild Queue</strong>
93+
</div>
94+
95+
<div class="about">
96+
<p>
97+
We continiously rebuild the latest versions for all crates so they can
98+
benefit from new features in rustdoc.
99+
</p>
100+
{%- if !expand_rebuild_queue -%}
101+
<p>There are currently {{ rebuild_queue.len() }} crates in the rebuild queue.</p>
102+
<p><a href="?expand=1">Show</a></p>
103+
{%- endif -%}
104+
</div>
105+
106+
{%- if expand_rebuild_queue -%}
107+
<ol class="queue-list">
108+
{%- if !rebuild_queue.is_empty() -%}
109+
{% for crate_item in rebuild_queue -%}
110+
<li>
111+
<a href="https://crates.io/crates/{{ crate_item.name }}">
112+
{{- crate_item.name }} {{ crate_item.version -}}
113+
</a>
114+
</li>
115+
{%- endfor %}
116+
{%- else %}
117+
<strong>There is nothing in the rebuild queue</strong>
118+
{%- endif %}
119+
</ol>
120+
{%- endif -%}
90121
</div>
91122
</div>
92123
{%- endblock body -%}

0 commit comments

Comments
 (0)