mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
(refs #26) Implements repository filter.
This commit is contained in:
@@ -48,7 +48,7 @@ trait DashboardControllerBase extends ControllerBase {
|
||||
countIssue(condition, Map.empty, repositories: _*),
|
||||
countIssue(condition, Map("assigned" -> userName), repositories: _*),
|
||||
countIssue(condition, Map("created_by" -> userName), repositories: _*),
|
||||
repositories,
|
||||
countIssueGroupByRepository(condition, filterUser, repositories: _*),
|
||||
condition,
|
||||
filter)
|
||||
|
||||
|
||||
@@ -80,6 +80,27 @@ trait IssuesService {
|
||||
}
|
||||
.toMap
|
||||
}
|
||||
/**
|
||||
* Returns list which contains issue count for each repository.
|
||||
* If the issue does not exist, its repository is not included in the result.
|
||||
*
|
||||
* @param condition the search condition
|
||||
* @param filterUser the filter user name (key is "all", "assigned" or "created_by", value is the user name)
|
||||
* @param repos Tuple of the repository owner and the repository name
|
||||
* @return list which contains issue count for each repository
|
||||
*/
|
||||
def countIssueGroupByRepository(condition: IssueSearchCondition, filterUser: Map[String, String],
|
||||
repos: (String, String)*): List[(String, String, Int)] = {
|
||||
searchIssueQuery(repos, condition.copy(repo = None), filterUser)
|
||||
.groupBy { t =>
|
||||
t.userName ~ t.repositoryName
|
||||
}
|
||||
.map { case (repo, t) =>
|
||||
repo ~ t.length
|
||||
}
|
||||
.filter (_._3 > 0.bind)
|
||||
.list
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the search result against issues.
|
||||
@@ -133,7 +154,10 @@ trait IssuesService {
|
||||
*/
|
||||
private def searchIssueQuery(repos: Seq[(String, String)], condition: IssueSearchCondition, filterUser: Map[String, String]) =
|
||||
Query(Issues) filter { t1 =>
|
||||
(repos.map { case (owner, repository) => t1.byRepository(owner, repository) } reduceLeft ( _ || _ ) ) &&
|
||||
(condition.repo
|
||||
.map { _.split('/') match { case array => Seq(array(0) -> array(1)) } }
|
||||
.getOrElse (repos)
|
||||
.map { case (owner, repository) => t1.byRepository(owner, repository) } reduceLeft ( _ || _ ) ) &&
|
||||
(t1.closed is (condition.state == "closed").bind) &&
|
||||
(t1.milestoneId is condition.milestoneId.get.get.bind, condition.milestoneId.flatten.isDefined) &&
|
||||
(t1.milestoneId isNull, condition.milestoneId == Some(None)) &&
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
allCount: Int,
|
||||
assignedCount: Int,
|
||||
createdByCount: Int,
|
||||
repositories: List[(String, String)],
|
||||
repositories: List[(String, String, Int)],
|
||||
condition: service.IssuesService.IssueSearchCondition,
|
||||
filter: String)(implicit context: app.Context)
|
||||
@import context._
|
||||
@@ -33,10 +33,10 @@
|
||||
</ul>
|
||||
<hr/>
|
||||
<ul class="nav nav-pills nav-stacked small">
|
||||
@repositories.map { case (owner, name) =>
|
||||
<li>
|
||||
@repositories.map { case (owner, name, count) =>
|
||||
<li@if(condition.repo == Some(owner + "/" + name)){ class="active"}>
|
||||
<a href="@condition.copy(repo = Some(owner + "/" + name)).toURL">
|
||||
<span class="count-right">0</span>
|
||||
<span class="count-right">@count</span>
|
||||
@owner/@name
|
||||
</a>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user