mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-03 03:55:58 +01:00
Add comment count sorting and displaying.
This commit is contained in:
@@ -95,22 +95,53 @@ trait IssuesService {
|
|||||||
* @param userName the filter user name required for "assigned" and "created_by"
|
* @param userName the filter user name required for "assigned" and "created_by"
|
||||||
* @param offset the offset for pagination
|
* @param offset the offset for pagination
|
||||||
* @param limit the limit for pagination
|
* @param limit the limit for pagination
|
||||||
* @return the count of the search result
|
* @return the search result (list of tuples which contain issue, labels and comment count)
|
||||||
*/
|
*/
|
||||||
def searchIssue(owner: String, repository: String, condition: IssueSearchCondition,
|
def searchIssue(owner: String, repository: String, condition: IssueSearchCondition,
|
||||||
filter: String, userName: Option[String], offset: Int, limit: Int): List[Issue] =
|
filter: String, userName: Option[String], offset: Int, limit: Int): List[(Issue, List[Label], Int)] = {
|
||||||
searchIssueQuery(owner, repository, condition, filter, userName).sortBy { t =>
|
|
||||||
|
// get issues and comment count
|
||||||
|
val issues = searchIssueQuery(owner, repository, condition, filter, userName)
|
||||||
|
.leftJoin(Query(IssueComments)
|
||||||
|
.filter { t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) }
|
||||||
|
.groupBy { _.issueId }
|
||||||
|
.map { case (issueId, t) => issueId ~ t.length }).on((t1, t2) => t1.issueId is t2._1)
|
||||||
|
.sortBy { case (t1, t2) =>
|
||||||
(condition.sort match {
|
(condition.sort match {
|
||||||
case "created" => t.registeredDate
|
case "created" => t1.registeredDate
|
||||||
case "comments" => t.updatedDate
|
case "comments" => t2._2
|
||||||
case "updated" => t.updatedDate
|
case "updated" => t1.updatedDate
|
||||||
}) match {
|
}) match {
|
||||||
case sort => condition.direction match {
|
case sort => condition.direction match {
|
||||||
case "asc" => sort asc
|
case "asc" => sort asc
|
||||||
case "desc" => sort desc
|
case "desc" => sort desc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} drop(offset) take(limit) list
|
}
|
||||||
|
.map { case (t1, t2) => (t1, t2._2.ifNull(0)) }
|
||||||
|
.drop(offset).take(limit)
|
||||||
|
.list
|
||||||
|
|
||||||
|
// get labels
|
||||||
|
val labels = Query(IssueLabels)
|
||||||
|
.innerJoin(Labels).on { (t1, t2) =>
|
||||||
|
(t1.userName is t2.userName) &&
|
||||||
|
(t1.repositoryName is t2.repositoryName) &&
|
||||||
|
(t1.labelId is t2.labelId)
|
||||||
|
}
|
||||||
|
.filter { case (t1, t2) =>
|
||||||
|
(t1.userName is owner.bind) &&
|
||||||
|
(t1.repositoryName is repository.bind) &&
|
||||||
|
(t1.issueId inSetBind (issues.map(_._1.issueId)))
|
||||||
|
}
|
||||||
|
.sortBy { case (t1, t2) => t1.issueId ~ t2.labelName }
|
||||||
|
.map { case (t1, t2) => (t1.issueId, t2) }
|
||||||
|
.list
|
||||||
|
|
||||||
|
issues.map { case (issue, commentCount) =>
|
||||||
|
(issue, labels.collect { case (issueId, labels) if(issueId == issue.issueId) => labels }, commentCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assembles query for conditional issue searching.
|
* Assembles query for conditional issue searching.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@(issues: List[model.Issue], page: Int, labels: List[model.Label], milestones: List[model.Milestone],
|
@(issues: List[(model.Issue, List[model.Label], Int)], page: Int, labels: List[model.Label], milestones: List[model.Milestone],
|
||||||
openCount: Int, closedCount: Int, allCount: Int, assignedCount: Option[Int], createdByCount: Option[Int], labelCounts: Map[String, Int],
|
openCount: Int, closedCount: Int, allCount: Int, assignedCount: Option[Int], createdByCount: Option[Int], labelCounts: Map[String, Int],
|
||||||
condition: service.IssuesService.IssueSearchCondition, filter: String,
|
condition: service.IssuesService.IssueSearchCondition, filter: String,
|
||||||
repository: service.RepositoryService.RepositoryInfo, isWritable: Boolean)(implicit context: app.Context)
|
repository: service.RepositoryService.RepositoryInfo, isWritable: Boolean)(implicit context: app.Context)
|
||||||
@@ -118,13 +118,22 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-bordered table-hover table-issues">
|
<table class="table table-bordered table-hover table-issues">
|
||||||
@issues.map { issue =>
|
@issues.map { case (issue, labels, commentCount) =>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="@path/@repository.owner/@repository.name/issues/@issue.issueId" class="issue-title">@issue.title</a>
|
<a href="@path/@repository.owner/@repository.name/issues/@issue.issueId" class="issue-title">@issue.title</a>
|
||||||
|
@labels.map { label =>
|
||||||
|
<span class="label-color" style="background-color: #@label.color; color: #@label.fontColor;">@label.labelName</span>
|
||||||
|
}
|
||||||
<span class="pull-right muted">#@issue.issueId</span>
|
<span class="pull-right muted">#@issue.issueId</span>
|
||||||
<div class="small muted">
|
<div class="small muted">
|
||||||
Opened by <a href="@path/@repository.owner" class="username">@issue.openedUserName</a> @datetime(issue.registeredDate)
|
Opened by <a href="@path/@repository.owner" class="username">@issue.openedUserName</a> @datetime(issue.registeredDate)
|
||||||
|
@if(commentCount == 1){
|
||||||
|
<i class="icon-comment"></i> 1 comment
|
||||||
|
}
|
||||||
|
@if(commentCount > 1){
|
||||||
|
<i class="icon-comment"></i> @commentCount comments
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user