Skip to content

Commit c9662a8

Browse files
authored
Merge pull request #3156 from codecrafters-io/refactor-simplify-active-repository-getter
refactor(course-overview): simplify activeRepository getter
2 parents bf0f198 + e118e7f commit c9662a8

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 completedStages() {

0 commit comments

Comments
 (0)