Skip to content

Commit

Permalink
Merge pull request #8116 from michaelchadwick/remove-unneeded-ilios-c…
Browse files Browse the repository at this point in the history
…ommon-slices

Remove unneeded ilios common slices
  • Loading branch information
michaelchadwick authored Sep 10, 2024
2 parents c303c20 + 3bb1258 commit bc440a1
Show file tree
Hide file tree
Showing 47 changed files with 94 additions and 103 deletions.
4 changes: 2 additions & 2 deletions packages/ilios-common/addon/classes/events-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class EventsBase extends Service {
const sessionTerms = await session.get('terms');
const course = await session.get('course');
const courseTerms = await course.get('terms');
return uniqueValues(mapBy([...sessionTerms.slice(), ...courseTerms.slice()], 'id'));
return uniqueValues(mapBy([...sessionTerms, ...courseTerms], 'id'));
}

/**
Expand Down Expand Up @@ -86,7 +86,7 @@ export default class EventsBase extends Service {
async getCohortIdsForEvent(event) {
const course = await this.getCourseForEvent(event);
const cohorts = await course.get('cohorts');
return mapBy(cohorts.slice(), 'id');
return mapBy(cohorts, 'id');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class CourseCollapsedObjectivesComponent extends Component {
});

get objectives() {
return this.objectivesRelationship ? this.objectivesRelationship.slice() : [];
return this.objectivesRelationship ? this.objectivesRelationship : [];
}

get objectivesWithParents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,21 @@ export default class CourseObjectiveListItemComponent extends Component {
return [...set, ...cohortObjectives.flat()];
}, []);
const parents = await this.args.courseObjective.programYearObjectives;
this.parentsBuffer = parents.slice().map((objective) => {
this.parentsBuffer = parents.map((objective) => {
return findById(objectives, objective.id);
});
this.isManagingParents = true;
});

manageDescriptors = dropTask(async () => {
const meshDescriptors = await this.args.courseObjective.meshDescriptors;
this.descriptorsBuffer = meshDescriptors.slice();
this.descriptorsBuffer = await this.args.courseObjective.meshDescriptors;
this.isManagingDescriptors = true;
});

manageTerms = dropTask(async (vocabulary) => {
this.selectedVocabulary = vocabulary;
const terms = await this.args.courseObjective.terms;
this.termsBuffer = terms.slice();
this.termsBuffer = terms;
this.isManagingTerms = true;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class CourseObjectiveListComponent extends Component {

get courseCohorts() {
if (this.load.lastSuccessful && this.courseCohortsAsync) {
return this.courseCohortsAsync.slice();
return this.courseCohortsAsync;
}

return [];
Expand Down Expand Up @@ -81,7 +81,7 @@ export default class CourseObjectiveListComponent extends Component {
'allowMultipleCourseObjectiveParents',
);
const objectives = await programYear.programYearObjectives;
const objectiveObjects = await map(objectives.slice(), async (objective) => {
const objectiveObjects = await map(objectives, async (objective) => {
let competencyId = 0;
let competencyTitle = intl.t('general.noAssociatedCompetency');
let competencyParent = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class CourseVisualizeInstructorSessionTypeGraph extends Component
return mapBy(allInstructors, 'id').includes(user.id);
});

const sessionsWithSessionType = await map(sessionsWithUser.slice(), async (session) => {
const sessionsWithSessionType = await map(sessionsWithUser, async (session) => {
const sessionType = await session.sessionType;
return {
session,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class CourseVisualizeInstructorComponent extends Component {
}

get sessions() {
return this.sessionsData.isResolved ? this.sessionsData.value.slice() : [];
return this.sessionsData.isResolved ? this.sessionsData.value : [];
}

@cached
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class CourseVisualizeObjectivesGraph extends Component {
async ({ session, minutes }) => {
const sessionObjectives = await session.sessionObjectives;
const sessionObjectivesWithParents = await filter(
sessionObjectives.slice(),
sessionObjectives,
async (sessionObjective) => {
const parents = await sessionObjective.courseObjectives;
return parents.length;
Expand All @@ -101,7 +101,7 @@ export default class CourseVisualizeObjectivesGraph extends Component {
sessionObjectivesWithParents,
async (sessionObjective) => {
const parents = await sessionObjective.courseObjectives;
return mapBy(parents.slice(), 'id');
return mapBy(parents, 'id');
},
);
const flatObjectives = courseSessionObjectives.reduce((flattened, arr) => {
Expand All @@ -119,8 +119,8 @@ export default class CourseVisualizeObjectivesGraph extends Component {

// condensed objectives map
const courseObjectives = await this.args.course.courseObjectives;
const mappedObjectives = await map(courseObjectives.slice(), async (courseObjective) => {
const programYearObjectives = (await courseObjective.programYearObjectives).slice();
const mappedObjectives = await map(courseObjectives, async (courseObjective) => {
const programYearObjectives = await courseObjective.programYearObjectives;
const competencyTitles = (
await map(programYearObjectives, async (pyObjective) => {
const competency = await pyObjective.competency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class CourseVisualizeVocabularyGraph extends Component {
sessionsWithMinutes,
async ({ session, minutes }) => {
const sessionTerms = await session.terms;
const sessionTermsInThisVocabulary = await filter(sessionTerms.slice(), async (term) => {
const sessionTermsInThisVocabulary = await filter(sessionTerms, async (term) => {
const termVocab = await term.vocabulary;
return termVocab.id === this.args.vocabulary.id;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export default class DashboardCalendarFiltersComponent extends Component {
async loadSessionTypes(school) {
await this.dataLoader.loadSchoolForCalendar(school.id);
const types = await school.sessionTypes;
return sortBy(types.slice(), 'title');
return sortBy(types, 'title');
}

async loadVocabularies(school) {
await this.dataLoader.loadSchoolForCalendar(school.id);
const vocabularies = await school.vocabularies;
await Promise.all(mapBy(vocabularies, 'terms'));
return sortBy(vocabularies.slice(), 'title');
return sortBy(vocabularies, 'title');
}
}
4 changes: 2 additions & 2 deletions packages/ilios-common/addon/components/dashboard/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ export default class DashboardCalendarComponent extends Component {
async getSchoolCohorts(school) {
await this.dataLoader.loadSchoolForCalendar(school.id);
const programs = await school.programs;
const programYears = await map(programs.slice(), async (program) => {
const programYears = await map(programs, async (program) => {
const programYears = await program.programYears;
return programYears.slice();
return programYears;
});
const cohorts = await Promise.all(mapBy(programYears.flat(), 'cohort'));
return cohorts.filter(Boolean);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class DashboardCoursesCalendarFilterComponent extends Component {
}

get courses() {
return this.coursesRelationship ? this.coursesRelationship.slice() : [];
return this.coursesRelationship ? this.coursesRelationship : [];
}

get courseYears() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class DashboardSelectedTermTreeComponent extends Component {
}

get children() {
return this.childrenData.isResolved ? this.childrenData.value.slice() : [];
return this.childrenData.isResolved ? this.childrenData.value : [];
}

get level() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class DetailCohortListComponent extends Component {
return false;
}

const sortProxies = await map(cohorts.slice(), async (cohort) => {
const sortProxies = await map(cohorts, async (cohort) => {
const programYear = await cohort.programYear;
const program = await programYear.program;
const school = await program.school;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class DetailCohortManagerComponent extends Component {
async loadCohorts(course) {
const school = await course.school;
const allCohorts = await this.store.findAll('cohort');
const cohortProxies = await map(allCohorts.slice(), async (cohort) => {
const cohortProxies = await map(allCohorts, async (cohort) => {
const programYear = await cohort.programYear;
const program = await programYear.program;
const school = await program.school;
Expand Down
2 changes: 1 addition & 1 deletion packages/ilios-common/addon/components/detail-cohorts.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class DetailCohortsComponent extends Component {

manage = dropTask(async () => {
const cohorts = await this.args.course.cohorts;
this.bufferedCohorts = [...cohorts.slice()];
this.bufferedCohorts = [...cohorts];
this.isManaging = true;
});

Expand Down
8 changes: 4 additions & 4 deletions packages/ilios-common/addon/components/detail-instructors.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export default class DetailInstructorsComponent extends Component {
instructors: ilmSession.instructors,
});

this.instructorGroupBuffer = instructorGroups.slice();
this.instructorBuffer = instructors.slice();
this.instructorGroupBuffer = instructorGroups;
this.instructorBuffer = instructors;
this.isManaging = true;
});

Expand All @@ -82,14 +82,14 @@ export default class DetailInstructorsComponent extends Component {
if (!this.ilmInstructors) {
return [];
}
return this.ilmInstructors.slice();
return this.ilmInstructors;
}

get selectedIlmInstructorGroups() {
if (!this.ilmInstructorGroups) {
return [];
}
return this.ilmInstructorGroups.slice();
return this.ilmInstructorGroups;
}

get instructorGroupCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export default class DetailLearnerGroupsListComponent extends Component {
return [];
}
const cohorts = uniqueValues(
await map(this.args.learnerGroups.slice(), async (learnerGroup) => {
await map(this.args.learnerGroups, async (learnerGroup) => {
return learnerGroup.cohort;
}),
);
return map(cohorts, async (cohort) => {
const groups = await filter(this.args.learnerGroups.slice(), async (group) => {
const groups = await filter(this.args.learnerGroups, async (group) => {
const groupCohort = await group.cohort;
return groupCohort === cohort;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export default class DetailLearnersAndLearnerGroupsComponent extends Component {
learners: ilmSession.learners,
});

this.learnerGroupBuffer = learnerGroups.slice();
this.learnerBuffer = learners.slice();
this.learnerGroupBuffer = learnerGroups;
this.learnerBuffer = learners;
this.isManaging = true;
});

Expand Down Expand Up @@ -96,14 +96,14 @@ export default class DetailLearnersAndLearnerGroupsComponent extends Component {
if (!this.ilmLearners) {
return [];
}
return this.ilmLearners.slice();
return this.ilmLearners;
}

get selectedIlmLearnerGroups() {
if (!this.ilmLearnerGroups) {
return [];
}
return this.ilmLearnerGroups.slice();
return this.ilmLearnerGroups;
}

@action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class DetailLearningMaterialsItemComponent extends Component {
}

get meshDescriptors() {
return this.meshDescriptorsData.isResolved ? this.meshDescriptorsData.value.slice() : [];
return this.meshDescriptorsData.isResolved ? this.meshDescriptorsData.value : [];
}

get meshDescriptorsLoaded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default class DetailCohortsComponent extends Component {

constructor() {
super(...arguments);
this.learningMaterialStatuses = this.store.peekAll('learning-material-status').slice();
this.learningMaterialUserRoles = this.store.peekAll('learning-material-user-role').slice();
this.learningMaterialStatuses = this.store.peekAll('learning-material-status');
this.learningMaterialUserRoles = this.store.peekAll('learning-material-user-role');
}

@cached
Expand Down
2 changes: 1 addition & 1 deletion packages/ilios-common/addon/components/detail-mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class DetailMeshComponent extends Component {
return [];
}

return this.meshDescriptorRelationship.slice();
return this.meshDescriptorRelationship;
}
@action
manage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class DetailTaxonomiesComponent extends Component {
manage = dropTask(async () => {
this.args.expand();
const terms = await this.args.subject.terms;
this.bufferedTerms = [...terms.slice()];
this.bufferedTerms = [...terms];
this.isManaging = true;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ export default class LearningMaterialManagerComponent extends Component {
this.startDate = learningMaterial.startDate;
this.endDate = learningMaterial.endDate;

const meshDescriptors = await learningMaterial.get('meshDescriptors');
this.terms = meshDescriptors.slice();

this.terms = await learningMaterial.meshDescriptors;
this.parentMaterial = parentMaterial;
this.type = parentMaterial.type;
this.title = parentMaterial.title;
Expand All @@ -193,10 +191,10 @@ export default class LearningMaterialManagerComponent extends Component {
this.filename = parentMaterial.filename;
this.uploadDate = parentMaterial.uploadDate;

const status = await parentMaterial.get('status');
const status = await parentMaterial.status;
this.statusId = status.id;
this.owningUser = await parentMaterial.get('owningUser');
const userRole = await parentMaterial.get('userRole');
this.owningUser = await parentMaterial.owningUser;
const userRole = await parentMaterial.userRole;
this.userRoleTitle = userRole.title;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class LearningMaterialSearchComponent extends Component {
'order_by[title]': 'ASC',
});
const lms = results.slice();
const lms = results;
this.searchReturned = true;
this.searching = false;
this.searchPage = 1;
Expand Down Expand Up @@ -59,7 +59,7 @@ export default class LearningMaterialSearchComponent extends Component {
offset: this.searchPage * this.searchResultsPerPage,
'order_by[title]': 'ASC',
});
const lms = results.slice();
const lms = results;
this.searchPage = this.searchPage + 1;
this.hasMoreSearchResults = lms.length > this.searchResultsPerPage;
if (this.hasMoreSearchResults) {
Expand Down
6 changes: 3 additions & 3 deletions packages/ilios-common/addon/components/offering-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class OfferingCalendar extends Component {
} else {
const data = await map(learnerGroups, async (learnerGroup) => {
const offerings = await learnerGroup.offerings;
return await map(offerings.slice(), async (offering) => {
return await map(offerings, async (offering) => {
const session = await offering.session;
const course = await session.course;
return {
Expand All @@ -88,7 +88,7 @@ export default class OfferingCalendar extends Component {
});

this.learnerGroupEvents = data.reduce((flattened, obj) => {
return [...flattened, ...obj.slice()];
return [...flattened, ...obj];
}, []);
}

Expand All @@ -99,7 +99,7 @@ export default class OfferingCalendar extends Component {
const offerings = await session.offerings;
const sessionType = await session.sessionType;
const course = await session.course;
this.sessionEvents = await map(offerings.slice(), async (offering) => {
this.sessionEvents = await map(offerings, async (offering) => {
return {
startDate: DateTime.fromJSDate(offering.startDate).toISO(),
endDate: DateTime.fromJSDate(offering.endDate).toISO(),
Expand Down
Loading

0 comments on commit bc440a1

Please sign in to comment.