Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions src/worker/jobs/daily_db_maintenance.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::tasks::spawn_blocking;
use crate::worker::Environment;
use crates_io_worker::BackgroundJob;
use diesel::{sql_query, RunQueryDsl};
use diesel_async::async_connection_wrapper::AsyncConnectionWrapper;
use diesel::sql_query;
use diesel_async::RunQueryDsl;
use std::sync::Arc;

#[derive(Serialize, Deserialize)]
Expand All @@ -24,15 +23,13 @@
/// archive daily download counts and drop historical data, we can drop this task and rely on
/// auto-vacuum again.
async fn run(&self, env: Self::Context) -> anyhow::Result<()> {
let conn = env.deadpool.get().await?;
spawn_blocking(move || {
let conn: &mut AsyncConnectionWrapper<_> = &mut conn.into();
let mut conn = env.deadpool.get().await?;

Check warning on line 26 in src/worker/jobs/daily_db_maintenance.rs

View check run for this annotation

Codecov / codecov/patch

src/worker/jobs/daily_db_maintenance.rs#L26

Added line #L26 was not covered by tests

info!("Running VACUUM on version_downloads table");
sql_query("VACUUM version_downloads;").execute(conn)?;
info!("Finished running VACUUM on version_downloads table");
Ok(())
})
.await
info!("Running VACUUM on version_downloads table");
sql_query("VACUUM version_downloads;")
.execute(&mut conn)
.await?;
info!("Finished running VACUUM on version_downloads table");
Ok(())

Check warning on line 33 in src/worker/jobs/daily_db_maintenance.rs

View check run for this annotation

Codecov / codecov/patch

src/worker/jobs/daily_db_maintenance.rs#L28-L33

Added lines #L28 - L33 were not covered by tests
}
}