@@ -6,9 +6,7 @@ use std::{
66
77use crate :: load:: { partition_in_place, SiteCtxt } ;
88use chrono:: { DateTime , NaiveDate , Utc } ;
9- use database:: {
10- BenchmarkRequest , BenchmarkRequestIndex , BenchmarkRequestStatus , BenchmarkRequestType ,
11- } ;
9+ use database:: { BenchmarkRequest , BenchmarkRequestIndex , BenchmarkRequestStatus } ;
1210use hashbrown:: HashSet ;
1311use parking_lot:: RwLock ;
1412use regex:: Regex ;
@@ -126,11 +124,7 @@ async fn create_benchmark_request_releases(
126124
127125 for ( name, date_time) in releases {
128126 if date_time >= cutoff && !index. contains_tag ( & name) {
129- let release_request = BenchmarkRequest :: create_release (
130- & name,
131- date_time,
132- BenchmarkRequestStatus :: ArtifactsReady ,
133- ) ;
127+ let release_request = BenchmarkRequest :: create_release ( & name, date_time) ;
134128 if let Err ( error) = conn. insert_benchmark_request ( & release_request) . await {
135129 log:: error!( "Failed to insert release benchmark request: {error}" ) ;
136130 }
@@ -147,11 +141,7 @@ fn sort_benchmark_requests(index: &BenchmarkRequestIndex, request_queue: &mut [B
147141 // Ensure all the items are ready to be sorted, if they are not this is
148142 // undefined behaviour
149143 assert ! ( request_queue. iter( ) . all( |bmr| {
150- bmr. status == BenchmarkRequestStatus :: ArtifactsReady
151- && matches!(
152- bmr. commit_type,
153- BenchmarkRequestType :: Master { .. } | BenchmarkRequestType :: Try { .. }
154- )
144+ bmr. status( ) == BenchmarkRequestStatus :: ArtifactsReady && ( bmr. is_master( ) || bmr. is_try( ) )
155145 } ) ) ;
156146
157147 let mut finished = 0 ;
@@ -180,15 +170,11 @@ fn sort_benchmark_requests(index: &BenchmarkRequestIndex, request_queue: &mut [B
180170 let level = & mut request_queue[ finished..] [ ..level_len] ;
181171 level. sort_unstable_by_key ( |bmr| {
182172 (
183- // Pr number takes priority
173+ // PR number takes priority
184174 * bmr. pr ( ) . unwrap_or ( & 0 ) ,
185175 // Order master commits before try commits
186- match bmr. commit_type {
187- BenchmarkRequestType :: Try { .. } => 1 ,
188- BenchmarkRequestType :: Master { .. } => 0 ,
189- BenchmarkRequestType :: Release { .. } => unreachable ! ( ) ,
190- } ,
191- bmr. created_at ,
176+ if bmr. is_master ( ) { 0 } else { 1 } ,
177+ bmr. created_at ( ) ,
192178 )
193179 } ) ;
194180 for c in level {
@@ -248,21 +234,21 @@ pub async fn build_queue(
248234 let mut pending = conn. load_pending_benchmark_requests ( ) . await ?;
249235
250236 // The queue starts with in progress
251- let mut queue: Vec < BenchmarkRequest > = pending
252- . extract_if_stable ( |request| matches ! ( request. status, BenchmarkRequestStatus :: InProgress ) ) ;
237+ let mut queue: Vec < BenchmarkRequest > = pending. extract_if_stable ( |request| {
238+ matches ! ( request. status( ) , BenchmarkRequestStatus :: InProgress )
239+ } ) ;
253240
254241 // We sort the in-progress ones based on the started date
255- queue. sort_unstable_by ( |a, b| a. created_at . cmp ( & b. created_at ) ) ;
242+ queue. sort_unstable_by ( |a, b| a. created_at ( ) . cmp ( & b. created_at ( ) ) ) ;
256243
257244 // Add release artifacts ordered by the release tag (1.87.0 before 1.88.0) and `created_at`.
258- let mut release_artifacts: Vec < BenchmarkRequest > = pending. extract_if_stable ( |request| {
259- matches ! ( request. commit_type, BenchmarkRequestType :: Release { .. } )
260- } ) ;
245+ let mut release_artifacts: Vec < BenchmarkRequest > =
246+ pending. extract_if_stable ( |request| request. is_release ( ) ) ;
261247
262248 release_artifacts. sort_unstable_by ( |a, b| {
263249 a. tag ( )
264250 . cmp ( & b. tag ( ) )
265- . then_with ( || a. created_at . cmp ( & b. created_at ) )
251+ . then_with ( || a. created_at ( ) . cmp ( & b. created_at ( ) ) )
266252 } ) ;
267253
268254 queue. append ( & mut release_artifacts) ;
0 commit comments