@@ -6,9 +6,7 @@ use std::{
6
6
7
7
use crate :: load:: { partition_in_place, SiteCtxt } ;
8
8
use chrono:: { DateTime , NaiveDate , Utc } ;
9
- use database:: {
10
- BenchmarkRequest , BenchmarkRequestIndex , BenchmarkRequestStatus , BenchmarkRequestType ,
11
- } ;
9
+ use database:: { BenchmarkRequest , BenchmarkRequestIndex , BenchmarkRequestStatus } ;
12
10
use hashbrown:: HashSet ;
13
11
use parking_lot:: RwLock ;
14
12
use regex:: Regex ;
@@ -126,11 +124,7 @@ async fn create_benchmark_request_releases(
126
124
127
125
for ( name, date_time) in releases {
128
126
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) ;
134
128
if let Err ( error) = conn. insert_benchmark_request ( & release_request) . await {
135
129
log:: error!( "Failed to insert release benchmark request: {error}" ) ;
136
130
}
@@ -147,11 +141,7 @@ fn sort_benchmark_requests(index: &BenchmarkRequestIndex, request_queue: &mut [B
147
141
// Ensure all the items are ready to be sorted, if they are not this is
148
142
// undefined behaviour
149
143
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( ) )
155
145
} ) ) ;
156
146
157
147
let mut finished = 0 ;
@@ -180,15 +170,11 @@ fn sort_benchmark_requests(index: &BenchmarkRequestIndex, request_queue: &mut [B
180
170
let level = & mut request_queue[ finished..] [ ..level_len] ;
181
171
level. sort_unstable_by_key ( |bmr| {
182
172
(
183
- // Pr number takes priority
173
+ // PR number takes priority
184
174
* bmr. pr ( ) . unwrap_or ( & 0 ) ,
185
175
// 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 ( ) ,
192
178
)
193
179
} ) ;
194
180
for c in level {
@@ -248,21 +234,21 @@ pub async fn build_queue(
248
234
let mut pending = conn. load_pending_benchmark_requests ( ) . await ?;
249
235
250
236
// 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
+ } ) ;
253
240
254
241
// 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 ( ) ) ) ;
256
243
257
244
// 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 ( ) ) ;
261
247
262
248
release_artifacts. sort_unstable_by ( |a, b| {
263
249
a. tag ( )
264
250
. cmp ( & b. tag ( ) )
265
- . then_with ( || a. created_at . cmp ( & b. created_at ) )
251
+ . then_with ( || a. created_at ( ) . cmp ( & b. created_at ( ) ) )
266
252
} ) ;
267
253
268
254
queue. append ( & mut release_artifacts) ;
0 commit comments