Skip to content

Conversation

@Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Nov 14, 2024

... to get rid of these pesky sync database connections.

I wish it would've been possible to split this into multiple commits, but... no 😅

@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Nov 14, 2024
@Turbo87 Turbo87 requested a review from LawnGnome November 14, 2024 16:56
@codecov
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 94.91525% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.22%. Comparing base (56e4a55) to head (4f0e106).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/typosquat/database.rs 95.23% 2 Missing ⚠️
src/worker/environment.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9937      +/-   ##
==========================================
- Coverage   89.23%   89.22%   -0.01%     
==========================================
  Files         292      292              
  Lines       30409    30434      +25     
==========================================
+ Hits        27135    27156      +21     
- Misses       3274     3278       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bors
Copy link
Contributor

bors commented Nov 16, 2024

☔ The latest upstream changes (presumably #9961) made this pull request unmergeable. Please resolve the merge conflicts.

@Turbo87 Turbo87 force-pushed the async-typosquat branch 2 times, most recently from 55e401e to 10234d5 Compare November 16, 2024 18:43
@bors
Copy link
Contributor

bors commented Nov 17, 2024

☔ The latest upstream changes (presumably #9973) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@LawnGnome LawnGnome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +46 to +65
let crates = models::Crate::all()
.inner_join(crate_downloads::table)
.order(crate_downloads::downloads.desc())
.limit(num)
.load_iter::<models::Crate, DefaultLoadingMode>(conn)?
{
let krate = result?;
crates.insert(
krate.id,
(
krate.name,
Crate {
owners: HashSet::new(),
},
),
);
}
.load_stream::<models::Crate>(conn)
.await?
.try_fold(crates, |mut crates, krate| {
crates.insert(
krate.id,
(
krate.name,
Crate {
owners: HashSet::new(),
},
),
);

futures_util::future::ready(Ok(crates))
})
.await?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just straight up better, async or no. 👍

@Turbo87 Turbo87 merged commit 1032ce9 into rust-lang:main Nov 18, 2024
10 checks passed
@Turbo87 Turbo87 deleted the async-typosquat branch November 18, 2024 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants