Skip to content

Commit

Permalink
models/crate: Add loadedVersionsByNum for lookup versions by num
Browse files Browse the repository at this point in the history
  • Loading branch information
eth3lbert committed Jan 10, 2025
1 parent c7685a3 commit 2188c2f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/models/crate.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ export default class Crate extends Model {
return Object.fromEntries(versions.slice().map(v => [v.id, v]));
}

/** @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]));
}

@cached get releaseTrackSet() {
let map = new Map();
let { versionsObj: versions, versionIdsBySemver } = this;
Expand Down

0 comments on commit 2188c2f

Please sign in to comment.