Skip to content

Commit

Permalink
worker/jobs/downloads/update_metadata: Remove crates.downloads colu…
Browse files Browse the repository at this point in the history
…mn writes
  • Loading branch information
Turbo87 committed Mar 6, 2024
1 parent ab82a55 commit 4af300e
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/worker/jobs/downloads/update_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ fn batch_update(batch_size: i64, conn: &mut PgConnection) -> QueryResult<i64> {
SELECT crate_id, SUM(downloads_batch.downloads) as downloads
FROM downloads_batch
GROUP BY crate_id
), updated_crates AS (
-- Update the `downloads` count for each crate.
UPDATE crates
SET downloads = crates.downloads + crate_downloads_batch.downloads
FROM crate_downloads_batch
WHERE crates.id = crate_downloads_batch.crate_id
), updated_crate_downloads AS (
-- Update the `downloads` count for each crate in the `crate_downloads` table.
UPDATE crate_downloads
Expand Down Expand Up @@ -237,12 +231,6 @@ mod tests {
.first(conn);
assert_eq!(version_downloads, Ok(1));

let crate_downloads = crates::table
.find(krate.id)
.select(crates::downloads)
.first(conn);
assert_eq!(crate_downloads, Ok(1));

let crate_downloads = crate_downloads::table
.find(krate.id)
.select(crate_downloads::downloads)
Expand Down Expand Up @@ -357,7 +345,6 @@ mod tests {
.filter(crates::id.eq(krate.id))
.first(conn)
.unwrap();
assert_eq!(krate2.downloads, 2);
assert_eq!(krate2.updated_at, krate_before.updated_at);

let krate2_downloads: i64 = crate_downloads::table
Expand Down

0 comments on commit 4af300e

Please sign in to comment.