diff --git a/src/main/scala/app/DashboardController.scala b/src/main/scala/app/DashboardController.scala index d0a40f0..719ed37 100644 --- a/src/main/scala/app/DashboardController.scala +++ b/src/main/scala/app/DashboardController.scala @@ -80,7 +80,7 @@ }.copy(repo = repository)) val userName = context.loginAccount.get.userName - val allRepos = getAllRepositories() + val allRepos = getAllRepositories(userName) val userRepos = getUserRepositories(userName, context.baseUrl, true).map(repo => repo.owner -> repo.name) val filterUser = Map(filter -> userName) val page = IssueSearchCondition.page(request) diff --git a/src/main/scala/service/RepositoryService.scala b/src/main/scala/service/RepositoryService.scala index 8e204a8..6305116 100644 --- a/src/main/scala/service/RepositoryService.scala +++ b/src/main/scala/service/RepositoryService.scala @@ -166,8 +166,18 @@ } } - def getAllRepositories()(implicit s: Session): List[(String, String)] = { - Repositories.sortBy(_.lastActivityDate desc).map{ t => + /** + * Returns the repositories without private repository that user does not have access right. + * Include public repository, private own repository and private but collaborator repository. + * + * @param userName the user name of collaborator + * @return the repository infomation list + */ + def getAllRepositories(userName: String)(implicit s: Session): List[(String, String)] = { + Repositories.filter { t1 => + (t1.isPrivate === false.bind) || + (Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && (t2.collaboratorName === userName.bind)} exists) + }.sortBy(_.lastActivityDate desc).map{ t => (t.userName, t.repositoryName) }.list }