Skip to content

Commit e118e7f

Browse files
committed
refactor(course-overview): simplify activeRepository getter
Replace complex filtering chain with direct sorting of userRepositories. This improves code readability and performance by avoiding multiple filterBy calls and creating fewer intermediate arrays. The change keeps the logic to return the most recent repository based on lastSubmissionAt.
1 parent f7ef756 commit e118e7f

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

app/controllers/course-overview.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,7 @@ export default class CourseOverviewController extends Controller {
1010
@service declare authenticator: AuthenticatorService;
1111

1212
get activeRepository(): RepositoryModel | null {
13-
if (this.authenticator.currentUser) {
14-
return (
15-
this.authenticator.currentUser.repositories
16-
.filterBy('course', this.model.course)
17-
.filterBy('firstSubmissionCreated')
18-
.sortBy('lastSubmissionAt')
19-
.toArray()
20-
.reverse()[0] || null
21-
);
22-
} else {
23-
return null;
24-
}
13+
return this.userRepositories.sortBy('lastSubmissionAt').toArray().reverse()[0] || null;
2514
}
2615

2716
get currentUser() {

0 commit comments

Comments
 (0)