-
Notifications
You must be signed in to change notification settings - Fork 27
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
Remove unneeded ilios common slices #8116
Remove unneeded ilios common slices #8116
Conversation
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.
Some additional refactoring possible and I think worth it for clarity. Also an open discussion item around passing a promise to RSVP.map
without the interim variable.
return findById(objectives, objective.id); | ||
}); | ||
this.isManagingParents = true; | ||
}); | ||
|
||
manageDescriptors = dropTask(async () => { | ||
const meshDescriptors = await this.args.courseObjective.meshDescriptors; | ||
this.descriptorsBuffer = meshDescriptors.slice(); |
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.
The entire purpose of this interim variable seems to be the slice. This might be the only time we notice this for a while so please replace with a direct assignment eg this.descriptorsBuffer = await this.args.courseObjective.meshDescriptors;
@@ -138,7 +138,7 @@ export default class LearningMaterialManagerComponent extends Component { | |||
this.endDate = learningMaterial.endDate; | |||
|
|||
const meshDescriptors = await learningMaterial.get('meshDescriptors'); |
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.
Unnecessary interim var.
@@ -59,20 +59,20 @@ export default class SessionObjectiveListItemComponent extends Component { | |||
|
|||
manageParents = dropTask(async () => { | |||
const parents = await this.args.sessionObjective.courseObjectives; | |||
this.parentsBuffer = parents.slice(); | |||
this.parentsBuffer = parents; |
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.
Unnecessary interim var.
this.isManagingParents = true; | ||
}); | ||
|
||
manageDescriptors = dropTask(async () => { | ||
const meshDescriptors = await this.args.sessionObjective.meshDescriptors; | ||
this.descriptorsBuffer = meshDescriptors.slice(); | ||
this.descriptorsBuffer = meshDescriptors; |
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.
Unnecessary interim var.
this.isManagingDescriptors = true; | ||
}); | ||
|
||
manageTerms = dropTask(async (vocabulary) => { | ||
this.selectedVocabulary = vocabulary; | ||
const terms = await this.args.sessionObjective.terms; | ||
this.termsBuffer = terms.slice(); | ||
this.termsBuffer = terms; |
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.
Unnecessary interim var.
@@ -87,7 +87,7 @@ export default class SessionsGrid extends Component { | |||
const offerings = await session.offerings; | |||
const learnerGroups = await map(offerings, async (offering) => { | |||
const learnerGroups = await offering.learnerGroups; | |||
return learnerGroups.slice(); | |||
return learnerGroups; |
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.
Unnecessary interim var.
@@ -15,7 +15,7 @@ export default class CourseVisualizeInstructorRoute extends Route { | |||
} | |||
|
|||
async afterModel({ course }) { | |||
const sessions = (await course.sessions).slice(); | |||
const sessions = await course.sessions; | |||
return await all([course.school, map(sessions, (s) => s.sessionType)]); |
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.
Interesting thing here. It looks like RSVP.map
will resolve a promise that is passed as the first argument. Really for discussion, but would it be cleaner to do this without the interim variable as just map(course.sessions, fn)
?
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.
Seems like a cromulent change. Probably need to do this across the site, but I'm checking to see if the change kills any tests now.
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.
Small additional since you're on this line already refactor and a left in log
and comment from debugging.
const meshDescriptors = await learningMaterial.get('meshDescriptors'); | ||
this.terms = meshDescriptors.slice(); | ||
|
||
this.terms = await learningMaterial.get('meshDescriptors'); |
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 should have noticed this the first time, sorry, this should be
this.terms = await learningMaterial.get('meshDescriptors'); | |
this.terms = await learningMaterial.meshDescriptors; |
and remove the old school Ember pattern of using get
here.
const sessions = (await course.sessions).slice(); | ||
return await all([course.school, map(sessions, (s) => s.sessionType)]); | ||
// const sessions = await course.sessions; | ||
console.log('CourseVisualizeInstructorRoute'); |
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.
OUTPUT: 😏
4d12a8f
to
3bb1258
Compare
References ilios/ilios#5660
Went through the
packages/ilios-common
directory and removed a bunch ofslice()
s. Left some I found because they had a.sort()
or[1]
or similar access thing that I know has thrown off our tests in the past.