File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ pub async fn run(opts: Opts) -> Result<()> {
36
36
info ! ( "Starting OG image rendering with options: {opts:?}" ) ;
37
37
38
38
// Helper function to build query
39
- let build_query = |offset : i64 | {
39
+ let build_query = || {
40
40
let mut query = crates:: table
41
41
. select ( crates:: name)
42
42
. order ( crates:: name)
@@ -46,16 +46,11 @@ pub async fn run(opts: Opts) -> Result<()> {
46
46
query = query. filter ( crates:: name. like ( format ! ( "{prefix}%" ) ) ) ;
47
47
}
48
48
49
- query. offset ( offset )
49
+ query
50
50
} ;
51
51
52
52
// Count total crates to process
53
- let mut count_query = crates:: table. into_boxed ( ) ;
54
- if let Some ( prefix) = & opts. prefix {
55
- count_query = count_query. filter ( crates:: name. like ( format ! ( "{prefix}%" ) ) ) ;
56
- }
57
- let total_crates: i64 = count_query. count ( ) . get_result ( & mut conn) . await ?;
58
-
53
+ let total_crates: i64 = build_query ( ) . count ( ) . get_result ( & mut conn) . await ?;
59
54
info ! ( "Total crates to enqueue: {total_crates}" ) ;
60
55
61
56
let mut offset = opts. offset . unwrap_or ( 0 ) ;
@@ -64,7 +59,8 @@ pub async fn run(opts: Opts) -> Result<()> {
64
59
65
60
loop {
66
61
// Fetch batch of crate names
67
- let crate_names: Vec < String > = build_query ( offset)
62
+ let crate_names: Vec < String > = build_query ( )
63
+ . offset ( offset)
68
64
. limit ( opts. batch_size as i64 )
69
65
. load ( & mut conn)
70
66
. await ?;
You can’t perform that action at this time.
0 commit comments