Skip to content
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

Include default_version by default #10344

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

eth3lbert
Copy link
Contributor

This PR would ensure that default_version is included in the crate response by default. This eliminates the need to wait for the versions request to complete when default_version is the only version required. This also decouples requested version handling from versions.

Related:

@eth3lbert eth3lbert force-pushed the app-default-version branch from a03882a to ddfede2 Compare January 8, 2025 16:25
Comment on lines +70 to +76
/** @return {Map<string, import("../models/version").default>} */
@cached
get loadedVersionsByNum() {
let versionsRef = this.hasMany('versions');
let values = versionsRef.value();
return new Map(values?.map(ref => [ref.num, ref]));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think versionsObj could also be changed to implement in this way. This would allow all versions that belong to this crate to be available, rather than just those loaded via the loadVersionsTask.

@eth3lbert
Copy link
Contributor Author

I have removed a commit that aimed to only await versions when needed. This commit fails in CI because we have some versions.length in the template, which would potentially load versions. I will address this in a separate PR, which will also require that the total number of versions be extracted from the meta.

app/adapters/crate.js Outdated Show resolved Hide resolved
app/adapters/version.js Outdated Show resolved Hide resolved
@eth3lbert eth3lbert force-pushed the app-default-version branch from ddfede2 to bfe8d72 Compare January 10, 2025 07:31
@eth3lbert
Copy link
Contributor Author

Rebased to make CI happy after the new Danger Zone was added :D

@eth3lbert eth3lbert force-pushed the app-default-version branch 2 times, most recently from 96786e2 to 433abe7 Compare January 13, 2025 14:09
This commit would ensure that `default_version` is included in the
`crate` response by default. This eliminates the need to wait for the
`versions` request to complete when `default_version` is the only
version required.
@eth3lbert eth3lbert force-pushed the app-default-version branch from 433abe7 to 59a975b Compare January 22, 2025 14:16
@eth3lbert
Copy link
Contributor Author

Rebased!

app/routes/crate/version-dependencies.js Outdated Show resolved Hide resolved
app/routes/crate/version-dependencies.js Outdated Show resolved Hide resolved
app/routes/crate/version.js Outdated Show resolved Hide resolved
Comment on lines 32 to 37
(await this.store
.queryRecord('version', {
name: crate.id,
num: requestedVersion,
})
.catch(() => {
// ignored
}));
Copy link
Member

Choose a reason for hiding this comment

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

if we still use crate.loadVersionsTask above, what is the reason for this fallback? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's a completely fair question. We still have dependencies on the versions (especially the version count), which makes the fallback seem unnecessary. The fallback would become valuable if we could load the page without blocking to wait for versions.

e2e/acceptance/crate-dependencies.spec.ts Outdated Show resolved Hide resolved
@Turbo87
Copy link
Member

Turbo87 commented Jan 23, 2025

also, sorry for keeping you waiting on this. I totally forgot about this PR 😞

@eth3lbert eth3lbert force-pushed the app-default-version branch from 59a975b to 901fc09 Compare January 23, 2025 14:48
Previously, we fetched all versions and then found the requested version
within them. This commit changes the approach to either retrieve the
version from loaded versions or fetch it from the endpoint. This change
allows us to migrate to paginated versions in the future.
@eth3lbert eth3lbert force-pushed the app-default-version branch from 901fc09 to 859959f Compare January 23, 2025 15:07
@eth3lbert eth3lbert requested a review from Turbo87 January 23, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants