Small fix for MilestonesService.

This commit is contained in:
takezoe
2013-06-26 15:11:45 +09:00
parent a5c5998fc8
commit 2b8cb7af48

View File

@@ -45,22 +45,16 @@ trait MilestonesService {
.sortBy(_.milestoneId desc)
.firstOption
def getMilestoneIssueCounts(owner: String, repository: String): Map[(Int, Boolean), Int] = {
import scala.slick.jdbc.GetResult
case class IssueCount(milestoneId: Int, closed: Boolean, count: Int)
implicit val getIssueCount = GetResult(r => IssueCount(r.<<, r.<<, r.<<))
def getMilestoneIssueCounts(owner: String, repository: String): Map[(Int, Boolean), Int] =
sql"""
select MILESTONE_ID, CLOSED, COUNT(ISSUE_ID)
from ISSUE
where USER_NAME = $owner AND REPOSITORY_NAME = $repository AND MILESTONE_ID IS NOT NULL
group by USER_NAME, REPOSITORY_NAME, MILESTONE_ID, CLOSED"""
.as[IssueCount]
.as[(Int, Boolean, Int)]
.list
.map { x => (x.milestoneId, x.closed) -> x.count }
.map { case (milestoneId, closed, count) => (milestoneId, closed) -> count }
.toMap
}
def getMilestones(owner: String, repository: String): List[Milestone] =
Query(Milestones)