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<()> {
3636 info ! ( "Starting OG image rendering with options: {opts:?}" ) ;
3737
3838 // Helper function to build query
39- let build_query = |offset : i64 | {
39+ let build_query = || {
4040 let mut query = crates:: table
4141 . select ( crates:: name)
4242 . order ( crates:: name)
@@ -46,16 +46,11 @@ pub async fn run(opts: Opts) -> Result<()> {
4646 query = query. filter ( crates:: name. like ( format ! ( "{prefix}%" ) ) ) ;
4747 }
4848
49- query. offset ( offset )
49+ query
5050 } ;
5151
5252 // 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 ?;
5954 info ! ( "Total crates to enqueue: {total_crates}" ) ;
6055
6156 let mut offset = opts. offset . unwrap_or ( 0 ) ;
@@ -64,7 +59,8 @@ pub async fn run(opts: Opts) -> Result<()> {
6459
6560 loop {
6661 // 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)
6864 . limit ( opts. batch_size as i64 )
6965 . load ( & mut conn)
7066 . await ?;
You can’t perform that action at this time.
0 commit comments