@@ -22,6 +22,7 @@ use axum::{
22
22
use base64:: { engine:: general_purpose:: STANDARD as b64, Engine } ;
23
23
use chrono:: { DateTime , Utc } ;
24
24
use futures_util:: stream:: TryStreamExt ;
25
+ use itertools:: Itertools ;
25
26
use once_cell:: sync:: Lazy ;
26
27
use rinja:: Template ;
27
28
use serde:: { Deserialize , Serialize } ;
@@ -832,7 +833,7 @@ pub(crate) async fn build_queue_handler(
832
833
. collect ( ) ;
833
834
834
835
let mut rebuild_queue = Vec :: new ( ) ;
835
- let queue : Vec < QueuedCrate > = build_queue
836
+ let mut queue = build_queue
836
837
. queued_crates ( )
837
838
. await ?
838
839
. into_iter ( )
@@ -842,19 +843,20 @@ pub(crate) async fn build_queue_handler(
842
843
* name == krate. name && * version == krate. version
843
844
} )
844
845
} )
845
- . map ( |mut krate| {
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
- }
846
+ . collect_vec ( ) ;
854
847
855
- krate
856
- } )
857
- . collect ( ) ;
848
+ queue. retain_mut ( |krate| {
849
+ if krate. priority >= REBUILD_PRIORITY {
850
+ rebuild_queue. push ( krate. clone ( ) ) ;
851
+ false
852
+ } else {
853
+ // The priority here is inverted: in the database if a crate has a higher priority it
854
+ // will be built after everything else, which is counter-intuitive for people not
855
+ // familiar with docs.rs's inner workings.
856
+ krate. priority = -krate. priority ;
857
+ true
858
+ }
859
+ } ) ;
858
860
859
861
Ok ( BuildQueuePage {
860
862
description : "crate documentation scheduled to build & deploy" ,
@@ -1901,15 +1903,29 @@ mod tests {
1901
1903
1902
1904
let full =
1903
1905
kuchikiki:: parse_html ( ) . one ( web. get ( "/releases/queue?expand=1" ) . send ( ) ?. text ( ) ?) ;
1904
- let items = full
1906
+ let build_queue_list = full
1907
+ . select ( ".queue-list > li" )
1908
+ . expect ( "missing list items" )
1909
+ . collect :: < Vec < _ > > ( ) ;
1910
+ let rebuild_queue_list = full
1905
1911
. select ( ".rebuild-queue-list > li" )
1906
1912
. expect ( "missing list items" )
1907
1913
. collect :: < Vec < _ > > ( ) ;
1908
1914
1909
- assert_eq ! ( items. len( ) , 2 ) ;
1910
- assert ! ( items. iter( ) . any( |li| li. text_contents( ) . contains( "foo" ) ) ) ;
1911
- assert ! ( items. iter( ) . any( |li| li. text_contents( ) . contains( "bar" ) ) ) ;
1912
- assert ! ( !items. iter( ) . any( |li| li. text_contents( ) . contains( "baz" ) ) ) ;
1915
+ assert_eq ! ( build_queue_list. len( ) , 1 ) ;
1916
+ assert_eq ! ( rebuild_queue_list. len( ) , 2 ) ;
1917
+ assert ! ( rebuild_queue_list
1918
+ . iter( )
1919
+ . any( |li| li. text_contents( ) . contains( "foo" ) ) ) ;
1920
+ assert ! ( rebuild_queue_list
1921
+ . iter( )
1922
+ . any( |li| li. text_contents( ) . contains( "bar" ) ) ) ;
1923
+ assert ! ( build_queue_list
1924
+ . iter( )
1925
+ . any( |li| li. text_contents( ) . contains( "baz" ) ) ) ;
1926
+ assert ! ( !rebuild_queue_list
1927
+ . iter( )
1928
+ . any( |li| li. text_contents( ) . contains( "baz" ) ) ) ;
1913
1929
1914
1930
Ok ( ( ) )
1915
1931
} ) ;
0 commit comments