diff --git a/src/main/scala/service/RepositoryService.scala b/src/main/scala/service/RepositoryService.scala index 518165c..056f7df 100644 --- a/src/main/scala/service/RepositoryService.scala +++ b/src/main/scala/service/RepositoryService.scala @@ -71,9 +71,16 @@ */ def getRepository(userName: String, repositoryName: String, baseUrl: String): Option[RepositoryInfo] = { (Query(Repositories) filter { t => t.byRepository(userName, repositoryName) } firstOption) map { repository => + // for getting issue count and pull request count + val issues = Query(Issues).filter { t => + t.byRepository(repository.userName, repository.repositoryName) && (t.closed is false.bind) + }.map(_.pullRequest).list + new RepositoryInfo( JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl), repository, + issues.size, + issues.filter(_ == true).size, getForkedCount( repository.originUserName.getOrElse(repository.userName), repository.originRepositoryName.getOrElse(repository.repositoryName) @@ -212,11 +219,20 @@ object RepositoryService { case class RepositoryInfo(owner: String, name: String, url: String, repository: Repository, - commitCount: Int, forkedCount: Int, branchList: List[String], tags: List[util.JGitUtil.TagInfo]){ + issueCount: Int, pullCount: Int, commitCount: Int, forkedCount: Int, + branchList: List[String], tags: List[util.JGitUtil.TagInfo]){ - def this(repo: JGitUtil.RepositoryInfo, model: Repository, forkedCount: Int) = { - this(repo.owner, repo.name, repo.url, model, repo.commitCount, forkedCount, repo.branchList, repo.tags) - } + /** + * Creates instance with issue count and pull request count. + */ + def this(repo: JGitUtil.RepositoryInfo, model: Repository, issueCount: Int, pullCount: Int, forkedCount: Int) = + this(repo.owner, repo.name, repo.url, model, issueCount, pullCount, repo.commitCount, forkedCount, repo.branchList, repo.tags) + + /** + * Creates instance without issue count and pull request count. + */ + def this(repo: JGitUtil.RepositoryInfo, model: Repository, forkedCount: Int) = + this(repo.owner, repo.name, repo.url, model, 0, 0, repo.commitCount, forkedCount, repo.branchList, repo.tags) } case class RepositoryTreeNode(owner: String, name: String, children: List[RepositoryTreeNode]) diff --git a/src/main/twirl/header.scala.html b/src/main/twirl/header.scala.html index abe952c..e565b18 100644 --- a/src/main/twirl/header.scala.html +++ b/src/main/twirl/header.scala.html @@ -8,7 +8,7 @@
- @repository.owner / @repository.name + @repository.owner / @repository.name @if(repository.repository.isPrivate){ } @@ -27,9 +27,15 @@ Issues + @if(repository.issueCount > 0){ + @repository.issueCount + } Pull Requests + @if(repository.pullCount > 0){ + @repository.pullCount + } Wiki