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

rm unneccessary calls to Array.slice() from ember-data models. #8088

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 3 additions & 6 deletions packages/ilios-common/addon/models/ilm-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ export default class IlmSession extends Model {
* @returns {Promise<Array>}
*/
async getAllInstructors() {
const instructors = (await this.instructors).slice();
const instructorGroups = (await this.instructorGroups).slice();
const instructors = await this.instructors;
const instructorGroups = await this.instructorGroups;
const instructorsInInstructorGroups = await Promise.all(mapBy(instructorGroups, 'users'));
return uniqueValues([
...instructors,
...instructorsInInstructorGroups.map((instructorGroup) => instructorGroup.slice()).flat(),
]);
return uniqueValues([...instructors, ...instructorsInInstructorGroups.flat()]);
}
}
2 changes: 1 addition & 1 deletion packages/ilios-common/addon/models/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ export default class SessionModel extends Model {

async getTotalSumOfferingsDurationByInstructor(user) {
const offerings = await this.offerings;
const offeringsWithUser = await filter(offerings.slice(), async (offering) => {
const offeringsWithUser = await filter(offerings, async (offering) => {
const instructors = await offering.getAllInstructors();
return mapBy(instructors, 'id').includes(user.id);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ilios-common/addon/models/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class Term extends Model {
}

async getAllDescendants() {
const children = (await this.children).slice();
const children = await this.children;
const childrenDescendants = await Promise.all(
children.map((child) => child.getAllDescendants()),
);
Expand Down
4 changes: 1 addition & 3 deletions packages/ilios-common/addon/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,7 @@ export default class User extends Model {
async getLowestMemberGroupInALearnerGroupTree(learnerGroupTree) {
const learnerGroups = await this.learnerGroups;
//all the groups a user is in that are in our current learner groups tree
const relevantGroups = learnerGroups
.slice()
.filter((group) => learnerGroupTree.includes(group));
const relevantGroups = learnerGroups.filter((group) => learnerGroupTree.includes(group));
const relevantGroupIds = mapBy(relevantGroups, 'id');
const lowestGroup = relevantGroups.find((group) => {
const childIds = group.hasMany('children').ids();
Expand Down
3 changes: 1 addition & 2 deletions packages/ilios-common/addon/models/vocabulary.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export default class Vocabulary extends Model {
terms;

async getTopLevelTerms() {
const terms = await this.terms;
return filter(terms.slice(), async (term) => {
return filter(this.terms, async (term) => {
stopfstedt marked this conversation as resolved.
Show resolved Hide resolved
return !(await term.parent);
});
}
Expand Down
Loading