Skip to content

Commit

Permalink
rm unnecessary slicing of ember-data collections into arrays.
Browse files Browse the repository at this point in the history
  • Loading branch information
stopfstedt committed Aug 19, 2024
1 parent 5946d53 commit b3fa9da
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class CourseVisualizeInstructorSessionTypeGraph extends Component
}

async getData(course, user) {
const sessions = (await course.sessions).slice();
const sessions = await course.sessions;
if (!sessions.length) {
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class CourseVisualizeInstructorTermGraph extends Component {
}

async getData(course, user) {
const sessions = (await course.sessions).slice();
const sessions = await course.sessions;
if (!sessions.length) {
return [];
}
Expand All @@ -75,7 +75,8 @@ export default class CourseVisualizeInstructorTermGraph extends Component {
});

const sessionsWithTerms = await map(sessionsWithUser, async (session) => {
const terms = await map((await session.terms).slice(), async (term) => {
const sessionTerms = await session.terms;
const terms = await map(sessionTerms, async (term) => {
const vocabulary = await term.vocabulary;
return {
term,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default class CourseVisualizeInstructorsGraph extends Component {
}

async getData(course) {
const sessions = (await course.sessions).slice();
const sessions = await course.sessions;
const sessionsWithInstructors = await map(sessions, async (session) => {
const instructors = await session.getAllInstructors();
const instructorsWithInstructionalTime = await map(instructors, async (instructor) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class CourseVisualizeObjectivesGraph 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 @@ -65,8 +65,8 @@ export default class CourseVisualizeSessionTypeGraph extends Component {
}

async getDataObjects(course, sessionType) {
const sessions = (await course.sessions).slice();
const sessionTypeSessions = (await sessionType.sessions).slice();
const sessions = await course.sessions;
const sessionTypeSessions = await sessionType.sessions;

const courseSessionsWithSessionType = sessions.filter((session) =>
sessionTypeSessions.includes(session),
Expand All @@ -81,7 +81,7 @@ export default class CourseVisualizeSessionTypeGraph extends Component {
});

const termData = await map(sessionsWithMinutes, async ({ session, minutes }) => {
const terms = (await session.terms).slice();
const terms = await session.terms;
return map(terms, async (term) => {
const vocabulary = await term.vocabulary;
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class CourseVisualizeSessionTypesGraph extends Component {
}

async getData(course) {
const sessions = (await course.sessions).slice();
const sessions = await course.sessions;

if (!sessions.length) {
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class CourseVisualizeTermGraph extends Component {
}

async getDataObjects(course, term) {
const sessions = (await course.sessions).slice();
const sessions = await course.sessions;
const sessionIds = term.hasMany('sessions').ids();
const filteredSessions = sessions.filter((session) => sessionIds.includes(session.id));
const sessionTypes = await Promise.all(filteredSessions.map((s) => s.sessionType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class CourseVisualizeVocabulariesGraph extends Component {
}

async getDataObjects(course) {
const sessions = (await course.sessions).slice();
const sessions = await course.sessions;
if (!sessions.length) {
return [];
}
Expand All @@ -82,7 +82,7 @@ export default class CourseVisualizeVocabulariesGraph extends Component {
const sessionWithMinutesAndVocabs = await map(
sessionsWithMinutes,
async ({ session, minutes }) => {
const terms = (await session.terms).slice();
const terms = await session.terms;
const vocabularies = await all(mapBy(terms, 'vocabulary'));
return {
session,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class CourseVisualizeVocabularyGraph extends Component {
}

async getDataObjects(course) {
const sessions = (await course.sessions).slice();
const sessions = await course.sessions;
if (!sessions.length) {
return [];
}
Expand Down

0 comments on commit b3fa9da

Please sign in to comment.