(refs #77)Display issue count and pull request count on the global nav.
1 parent fd0169d commit 5f2d62030ffd2007ba1de0daf75e63ceefb97160
@takezoe takezoe authored on 16 Aug 2013
Showing 2 changed files
View
35
src/main/scala/service/RepositoryService.scala
* @return the repository information
*/
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)
))
 
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]){
 
def this(repo: JGitUtil.RepositoryInfo, model: Repository, forkedCount: Int) = {
this(repo.owner, repo.name, repo.url, model, repo.commitCount, forkedCount, repo.branchList, repo.tags)
}
issueCount: Int, pullCount: Int, commitCount: Int, forkedCount: Int,
branchList: List[String], tags: List[util.JGitUtil.TagInfo]){
 
/**
* 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])
 
View
8
src/main/twirl/header.scala.html
<span class="add-on"><a href="@url(repository)/network/members">@repository.forkedCount</a></span>
</div>
</div>
<div class="head">
<a href="@url(repository.owner)">@repository.owner</a> / <a href="@url(repository)">@repository.name</a>
<a href="@url(repository.owner)">@repository.owner</a> / <a href="@url(repository)" class="strong">@repository.name</a>
@if(repository.repository.isPrivate){
<i class="icon-lock"></i>
}
@defining(repository.repository){ x =>
<a href="@url(repository)">Code</a>
</th>
<th class="box-header@if(active=="issues"){ active}">
<a href="@url(repository)/issues">Issues</a>
@if(repository.issueCount > 0){
<span class="badge">@repository.issueCount</span>
}
</th>
<th class="box-header@if(active=="pulls"){ active}">
<a href="@url(repository)/pulls">Pull Requests</a>
@if(repository.pullCount > 0){
<span class="badge">@repository.pullCount</span>
}
</th>
<th class="box-header@if(active=="wiki"){ active}">
<a href="@url(repository)/wiki">Wiki</a>
</th>