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

Simplify releaseTrackSet using release_tracks meta #10248

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

eth3lbert
Copy link
Contributor

This is a follow-up PR to #10214 that simplifies releaseTrackSet using release_tracks meta. As part of this transition, we also ensure that versions are loaded from a separate request. In other words, we ask the crate API to not include the versions data by default.

This is also part of eliminating the need for versions to be sorted again within the app. Therefore, the next step would be to leverage sorted data from endpoint without recalculating it within the app.

Comment on lines +150 to 163
/**
* @param {Object} [Options]
* @param {bool} [Options.reload]
* @param {bool} [Options.withReleaseTracks] - default: true if it has not yet been loaded else false
**/
loadVersionsTask = task(async ({ reload = false, withReleaseTracks } = {}) => {
let versionsRef = this.hasMany('versions');
let opts = { adapterOptions: { withReleaseTracks } };
if (opts.adapterOptions.withReleaseTracks == null) {
opts.adapterOptions.withReleaseTracks = this?.versions_meta?.release_tracks == null;
}
let fut = reload === true ? versionsRef.reload(opts) : versionsRef.load(opts);
return (await fut) ?? [];
});
Copy link
Contributor Author

@eth3lbert eth3lbert Dec 19, 2024

Choose a reason for hiding this comment

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

I think we could also consider extending this to two tasks: a parent task to calculate the options, and a child task to perform the actual API request.

The reason for this is that for reload, we likely want to request with the same options. However, with a single task and no other state to hold the calculated options (withReleaseTracks), the value might change. If a child task is introduced, we could use last.args as calculated options.

@eth3lbert
Copy link
Contributor Author

After rethinking this a bit, perhaps the version-related functionality might be worth moving from the crate model to a dedicated service. If we aim to eliminate the need for sorting versions within the application, we likely need to store sorted versions (or indexes should suffice). Otherwise, with only store, we would still need to perform a sorting operation to obtain sorted versions.

Therefore, it would be more beneficial to simply extract these functionalities into a dedicated service that handles loading a crate's versions, release_tracks, and sorted indexes.

I'll make a change for the above reason.

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