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) .sortBy(_.milestoneId desc)
.firstOption .firstOption
def getMilestoneIssueCounts(owner: String, repository: String): Map[(Int, Boolean), Int] = { 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.<<))
sql""" sql"""
select MILESTONE_ID, CLOSED, COUNT(ISSUE_ID) select MILESTONE_ID, CLOSED, COUNT(ISSUE_ID)
from ISSUE from ISSUE
where USER_NAME = $owner AND REPOSITORY_NAME = $repository AND MILESTONE_ID IS NOT NULL where USER_NAME = $owner AND REPOSITORY_NAME = $repository AND MILESTONE_ID IS NOT NULL
group by USER_NAME, REPOSITORY_NAME, MILESTONE_ID, CLOSED""" group by USER_NAME, REPOSITORY_NAME, MILESTONE_ID, CLOSED"""
.as[IssueCount] .as[(Int, Boolean, Int)]
.list .list
.map { x => (x.milestoneId, x.closed) -> x.count } .map { case (milestoneId, closed, count) => (milestoneId, closed) -> count }
.toMap .toMap
}
def getMilestones(owner: String, repository: String): List[Milestone] = def getMilestones(owner: String, repository: String): List[Milestone] =
Query(Milestones) Query(Milestones)