@@ -175,16 +175,35 @@ impl SiteCtxt {
175
175
}
176
176
}
177
177
178
+ /// Calculating the missing commits.
178
179
fn calculate_missing (
180
+ master_commits : Vec < collector:: MasterCommit > ,
181
+ queued_pr_commits : Vec < database:: QueuedCommit > ,
182
+ in_progress_artifacts : Vec < ArtifactId > ,
183
+ all_commits : HashSet < String > ,
184
+ ) -> Vec < ( Commit , MissingReason ) > {
185
+ calculate_missing_from (
186
+ master_commits,
187
+ queued_pr_commits,
188
+ in_progress_artifacts,
189
+ all_commits,
190
+ Utc :: now ( ) ,
191
+ )
192
+ }
193
+
194
+ /// Calculate the missing commits filtering out any that are 29 days or older than the supplied time.
195
+ ///
196
+ /// This is used by `calculate_missing` is exists as a separate function for testing purposes.
197
+ fn calculate_missing_from (
179
198
master_commits : Vec < collector:: MasterCommit > ,
180
199
queued_pr_commits : Vec < database:: QueuedCommit > ,
181
200
in_progress_artifacts : Vec < ArtifactId > ,
182
201
mut all_commits : HashSet < String > ,
202
+ time : chrono:: DateTime < chrono:: Utc > ,
183
203
) -> Vec < ( Commit , MissingReason ) > {
184
- let now = Utc :: now ( ) ;
185
204
let mut master_commits = master_commits
186
205
. into_iter ( )
187
- . filter ( |c| now . signed_duration_since ( c. time ) < Duration :: days ( 29 ) )
206
+ . filter ( |c| time . signed_duration_since ( c. time ) < Duration :: days ( 29 ) )
188
207
. map ( |c| {
189
208
(
190
209
Commit {
@@ -359,11 +378,12 @@ mod tests {
359
378
] ;
360
379
assert_eq ! (
361
380
expected,
362
- calculate_missing (
381
+ calculate_missing_from (
363
382
master_commits,
364
383
queued_pr_commits,
365
384
in_progress_artifacts,
366
- all_commits
385
+ all_commits,
386
+ time
367
387
)
368
388
) ;
369
389
}
0 commit comments