mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 23:15:49 +01:00
Retrieve open and closed issue count from DB.
This commit is contained in:
@@ -91,6 +91,8 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
issues.html.issues(searchIssue(owner, repository, condition, filter, userName),
|
||||
getLabels(owner, repository),
|
||||
getMilestones(owner, repository).filter(_.closedDate.isEmpty),
|
||||
countIssue(owner, repository, condition.copy(state = "open"), filter, userName),
|
||||
countIssue(owner, repository, condition.copy(state = "closed"), filter, userName),
|
||||
condition, filter, repositoryInfo, isWritable(owner, repository, context.loginAccount))
|
||||
|
||||
} getOrElse NotFound
|
||||
|
||||
@@ -28,16 +28,31 @@ trait IssuesService {
|
||||
(t.issueId is issueId.bind)
|
||||
} list
|
||||
|
||||
/**
|
||||
* Returns the count of the search result against issues.
|
||||
*
|
||||
* @param owner the repository owner
|
||||
* @param repository the repository name
|
||||
* @param condition the search condition
|
||||
* @param filter the filter type ("all", "assigned" or "created_by")
|
||||
* @param userName the filter user name required for "assigned" and "created_by"
|
||||
* @return the count of the search result
|
||||
*/
|
||||
def countIssue(owner: String, repository: String, condition: IssueSearchCondition, filter: String, userName: Option[String]): Int =
|
||||
searchIssueQuery(owner, repository, condition, filter, userName) map (_.length) first
|
||||
|
||||
/**
|
||||
* Returns the search result against issues.
|
||||
*
|
||||
* @param owner the repository owner
|
||||
* @param repository the repository name
|
||||
* @param condition the search condition
|
||||
* @param filter the filter type ("all", "assigned" or "created_by")
|
||||
* @param userName the filter user name required for "assigned" and "created_by"
|
||||
* @return the count of the search result
|
||||
*/
|
||||
def searchIssue(owner: String, repository: String, condition: IssueSearchCondition, filter: String, userName: Option[String]) =
|
||||
Query(Issues) filter { t =>
|
||||
(t.userName is owner.bind) &&
|
||||
(t.repositoryName is repository.bind) &&
|
||||
(t.closed is (condition.state == "closed").bind) &&
|
||||
(t.milestoneId is condition.milestoneId.get.bind, condition.milestoneId.isDefined) &&
|
||||
//if(condition.labels.nonEmpty) Some(Query(Issue)) else None,
|
||||
(t.assignedUserName is userName.get.bind, filter == "assigned") &&
|
||||
(t.openedUserName is userName.get.bind, filter == "created_by")
|
||||
} sortBy { t =>
|
||||
searchIssueQuery(owner, repository, condition, filter, userName).sortBy { t =>
|
||||
(condition.sort match {
|
||||
case "created" => t.registeredDate
|
||||
case "comments" => t.updatedDate
|
||||
@@ -50,6 +65,20 @@ trait IssuesService {
|
||||
}
|
||||
} list
|
||||
|
||||
/**
|
||||
* Assembles query for conditional issue searching.
|
||||
*/
|
||||
private def searchIssueQuery(owner: String, repository: String, condition: IssueSearchCondition, filter: String, userName: Option[String]) =
|
||||
Query(Issues) filter { t =>
|
||||
(t.userName is owner.bind) &&
|
||||
(t.repositoryName is repository.bind) &&
|
||||
(t.closed is (condition.state == "closed").bind) &&
|
||||
(t.milestoneId is condition.milestoneId.get.bind, condition.milestoneId.isDefined) &&
|
||||
//if(condition.labels.nonEmpty) Some(Query(Issue)) else None,
|
||||
(t.assignedUserName is userName.get.bind, filter == "assigned") &&
|
||||
(t.openedUserName is userName.get.bind, filter == "created_by")
|
||||
}
|
||||
|
||||
def saveIssue(owner: String, repository: String, loginUser: String,
|
||||
title: String, content: Option[String]) =
|
||||
// next id number
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@(issues: List[model.Issue], labels: List[model.Label], milestones: List[model.Milestone],
|
||||
openCount: Int, closedCount: Int,
|
||||
condition: service.IssuesService.IssueSearchCondition, filter: String,
|
||||
repository: service.RepositoryService.RepositoryInfo, isWritable: Boolean)(implicit context: app.Context)
|
||||
@import context._
|
||||
@@ -91,8 +92,8 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a class="btn@if(condition.state == "open"){ active}" href="@condition.copy(state = "open").toURL">1 Open</a>
|
||||
<a class="btn@if(condition.state == "closed"){ active}" href="@condition.copy(state = "closed").toURL">1 Closed</a>
|
||||
<a class="btn@if(condition.state == "open"){ active}" href="@condition.copy(state = "open").toURL">@openCount Open</a>
|
||||
<a class="btn@if(condition.state == "closed"){ active}" href="@condition.copy(state = "closed").toURL">@closedCount Closed</a>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown">
|
||||
|
||||
Reference in New Issue
Block a user