-
Notifications
You must be signed in to change notification settings - Fork 607
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
base: main
Are you sure you want to change the base?
Conversation
Wait before calling `evaluateAll()` to ensure all rows are available.
This also always
… by default This will ensure that `versions` is always fetched via a separate request, rather than being included in `crate` response. This allow us to migrate to a paginated version list in the future.
/** | ||
* @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) ?? []; | ||
}); |
There was a problem hiding this comment.
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.
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. |
This is a follow-up PR to #10214 that simplifies
releaseTrackSet
usingrelease_tracks
meta. As part of this transition, we also ensure thatversions
are loaded from a separate request. In other words, we ask thecrate
API to not include theversions
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.