mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 14:05:52 +01:00
(refs #2)Add opened user filter and count to the pull request list.
This commit is contained in:
@@ -386,10 +386,12 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
pulls.html.list(
|
pulls.html.list(
|
||||||
searchIssue(condition, filterUser, true, (page - 1) * PullRequestLimit, PullRequestLimit, owner -> repoName),
|
searchIssue(condition, filterUser, true, (page - 1) * PullRequestLimit, PullRequestLimit, owner -> repoName),
|
||||||
|
getPullRequestCount(condition.state == "closed", Some(owner, repoName)),
|
||||||
userName,
|
userName,
|
||||||
page,
|
page,
|
||||||
countIssue(condition.copy(state = "open"), filterUser, true, owner -> repoName),
|
countIssue(condition.copy(state = "open"), filterUser, true, owner -> repoName),
|
||||||
countIssue(condition.copy(state = "closed"), filterUser, true, owner -> repoName),
|
countIssue(condition.copy(state = "closed"), filterUser, true, owner -> repoName),
|
||||||
|
countIssue(condition, Map.empty, true, owner -> repoName),
|
||||||
condition,
|
condition,
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(owner, repoName, context.loginAccount))
|
hasWritePermission(owner, repoName, context.loginAccount))
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import Database.threadLocalSession
|
|||||||
import model._
|
import model._
|
||||||
|
|
||||||
trait PullRequestService { self: IssuesService =>
|
trait PullRequestService { self: IssuesService =>
|
||||||
|
import PullRequestService._
|
||||||
|
// implicit val getPullRequestCount = GetResult(r => PullRequestCount(r.<<, r.<<))
|
||||||
|
|
||||||
def getPullRequest(owner: String, repository: String, issueId: Int): Option[(Issue, PullRequest)] = {
|
def getPullRequest(owner: String, repository: String, issueId: Int): Option[(Issue, PullRequest)] = {
|
||||||
val issue = getIssue(owner, repository, issueId.toString)
|
val issue = getIssue(owner, repository, issueId.toString)
|
||||||
@@ -17,6 +19,27 @@ trait PullRequestService { self: IssuesService =>
|
|||||||
} else None
|
} else None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getPullRequestCount(closed: Boolean, repository: Option[(String, String)]): List[PullRequestCount] = {
|
||||||
|
Query(PullRequests)
|
||||||
|
.innerJoin(Issues).on { (t1, t2) => t1.byPrimaryKey(t2.userName, t2.repositoryName, t2.issueId) }
|
||||||
|
.filter { case (t1, t2) =>
|
||||||
|
(t2.closed is closed.bind) &&
|
||||||
|
(t1.userName is repository.get._1, repository.isDefined) &&
|
||||||
|
(t1.repositoryName is repository.get._2, repository.isDefined)
|
||||||
|
}
|
||||||
|
.groupBy { case (t1, t2) =>
|
||||||
|
t2.openedUserName
|
||||||
|
}
|
||||||
|
.map { case (userName, t) =>
|
||||||
|
userName ~ t.length
|
||||||
|
}
|
||||||
|
.list
|
||||||
|
.map { x =>
|
||||||
|
PullRequestCount(x._1, x._2)
|
||||||
|
}
|
||||||
|
.sortBy(_.count).reverse
|
||||||
|
}
|
||||||
|
|
||||||
def createPullRequest(originUserName: String, originRepositoryName: String, issueId: Int,
|
def createPullRequest(originUserName: String, originRepositoryName: String, issueId: Int,
|
||||||
originBranch: String, requestUserName: String, requestRepositoryName: String, requestBranch: String,
|
originBranch: String, requestUserName: String, requestRepositoryName: String, requestBranch: String,
|
||||||
commitIdFrom: String, commitIdTo: String): Unit =
|
commitIdFrom: String, commitIdTo: String): Unit =
|
||||||
@@ -34,5 +57,9 @@ trait PullRequestService { self: IssuesService =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
object PullRequestService {
|
object PullRequestService {
|
||||||
|
|
||||||
val PullRequestLimit = 25
|
val PullRequestLimit = 25
|
||||||
|
|
||||||
|
case class PullRequestCount(userName: String, count: Int)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
@(issues: List[(model.Issue, List[model.Label], Int)],
|
@(issues: List[(model.Issue, List[model.Label], Int)],
|
||||||
|
counts: List[service.PullRequestService.PullRequestCount],
|
||||||
filter: Option[String],
|
filter: Option[String],
|
||||||
page: Int,
|
page: Int,
|
||||||
openCount: Int,
|
openCount: Int,
|
||||||
closedCount: Int,
|
closedCount: Int,
|
||||||
|
allCount: Int,
|
||||||
condition: service.IssuesService.IssueSearchCondition,
|
condition: service.IssuesService.IssueSearchCondition,
|
||||||
repository: service.RepositoryService.RepositoryInfo,
|
repository: service.RepositoryService.RepositoryInfo,
|
||||||
hasWritePermission: Boolean)(implicit context: app.Context)
|
hasWritePermission: Boolean)(implicit context: app.Context)
|
||||||
@@ -15,19 +17,32 @@
|
|||||||
<ul class="nav nav-pills nav-stacked">
|
<ul class="nav nav-pills nav-stacked">
|
||||||
<li@if(filter.isEmpty){ class="active"}>
|
<li@if(filter.isEmpty){ class="active"}>
|
||||||
<a href="@url(repository)/pulls">
|
<a href="@url(repository)/pulls">
|
||||||
<span class="count-right">@(openCount + closedCount)</span>
|
<span class="count-right">@allCount</span>
|
||||||
All Requests
|
All Requests
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@if(loginAccount.isDefined){
|
@if(loginAccount.isDefined){
|
||||||
<li@if(filter.isDefined && filter.get == loginAccount.get.userName){ class="active"}>
|
<li@if(filter.map(_ == loginAccount.get.userName).getOrElse(false)){ class="active"}>
|
||||||
<a href="@url(repository)/pulls/@loginAccount.map(_.userName)">
|
<a href="@url(repository)/pulls/@loginAccount.map(_.userName)">
|
||||||
<span class="count-right">0</span>
|
<span class="count-right">@counts.find(_.userName == loginAccount.get.userName).map(_.count)</span>
|
||||||
Yours
|
Yours
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
|
<hr>
|
||||||
|
<ul class="nav nav-pills nav-stacked small">
|
||||||
|
@counts.map { user =>
|
||||||
|
@if(loginAccount.isEmpty || loginAccount.get.userName != user.userName){
|
||||||
|
<li@if(filter.map(_ == user.userName).getOrElse(false)){ class="active"}>
|
||||||
|
<a href="@url(repository)/pulls/@user.userName">
|
||||||
|
<span class="count-right">@user.count</span>
|
||||||
|
@user.userName
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="span9">
|
<div class="span9">
|
||||||
@if(hasWritePermission){
|
@if(hasWritePermission){
|
||||||
|
|||||||
Reference in New Issue
Block a user