Skip to content

fix: get_package_version waterfall #1064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 11 additions & 7 deletions api/src/api/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use deno_graph::Resolution;
use deno_graph::WorkspaceMember;
use deno_semver::StackString;
use futures::future::Either;
use futures::stream::FuturesUnordered;
use futures::StreamExt;
use hyper::body::HttpBody;
use hyper::Body;
Expand Down Expand Up @@ -1654,18 +1655,21 @@ pub async fn get_downloads_handler(
let recent_versions = db
.list_latest_unyanked_versions_for_package(&scope, &package, 5)
.await?;

let versions = futures::stream::iter(recent_versions.into_iter())
.then(|version| async {
let futures = FuturesUnordered::new();
for version in recent_versions {
let scope_ = scope.clone();
let package_ = package.clone();
futures.push(async move {
let res = db
.get_package_version_downloads_24h(
&scope, &package, &version, start, current,
&scope_, &package_, &version, start, current,
)
.await;
(version, res)
})
.collect::<Vec<_>>()
.await;
});
}

let versions = futures.collect::<Vec<_>>().await;

let mut recent_versions = Vec::with_capacity(versions.len());
for (version, downloads) in versions {
Expand Down
Loading