mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 22:45:51 +01:00
MilestonesService provides a method which returns milestones with issue count.
This commit is contained in:
@@ -28,8 +28,7 @@ trait MilestonesControllerBase extends ControllerBase {
|
||||
|
||||
getRepository(owner, repository, baseUrl).map { repositoryInfo =>
|
||||
issues.html.milestones(state,
|
||||
getMilestones(owner, repository),
|
||||
getMilestoneIssueCounts(owner, repository),
|
||||
getMilestonesWithIssueCount(owner, repository),
|
||||
repositoryInfo,
|
||||
isWritable(owner, repository, context.loginAccount))
|
||||
} getOrElse NotFound
|
||||
|
||||
@@ -61,8 +61,8 @@ trait MilestonesService {
|
||||
.sortBy(_.milestoneId desc)
|
||||
.firstOption
|
||||
|
||||
def getMilestoneIssueCounts(owner: String, repository: String): Map[(Int, Boolean), Int] =
|
||||
Issues
|
||||
def getMilestonesWithIssueCount(owner: String, repository: String): List[(Milestone, Int, Int)] = {
|
||||
val counts = Issues
|
||||
.filter { t =>
|
||||
(t.userName is owner.bind) &&
|
||||
(t.repositoryName is repository.bind) &&
|
||||
@@ -80,6 +80,11 @@ trait MilestonesService {
|
||||
}
|
||||
.toMap
|
||||
|
||||
getMilestones(owner, repository).map { milestone =>
|
||||
(milestone, counts.getOrElse((milestone.milestoneId, false), 0), counts.getOrElse((milestone.milestoneId, true), 0))
|
||||
}
|
||||
}
|
||||
|
||||
def getMilestones(owner: String, repository: String): List[Milestone] =
|
||||
Query(Milestones)
|
||||
.filter { t =>
|
||||
|
||||
Reference in New Issue
Block a user