From 6a06b908b72d7fa09f382aff4fb7fbd3fbc73f4e Mon Sep 17 00:00:00 2001 From: takezoe Date: Wed, 26 Jun 2013 16:04:32 +0900 Subject: [PATCH] Delete LABEL_ISSUE before deleting LABEL. --- src/main/scala/service/LabelsService.scala | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/scala/service/LabelsService.scala b/src/main/scala/service/LabelsService.scala index 83151ab15..25f0938e3 100644 --- a/src/main/scala/service/LabelsService.scala +++ b/src/main/scala/service/LabelsService.scala @@ -2,23 +2,20 @@ package service import scala.slick.driver.H2Driver.simple._ import Database.threadLocalSession -import scala.slick.jdbc.{StaticQuery => Q} -import Q.interpolation import model._ -import Labels._ trait LabelsService { def getLabels(owner: String, repository: String): List[Label] = Query(Labels) - .filter(l => (l.userName is owner.bind) && (l.repositoryName is repository.bind)) + .filter(t => (t.userName is owner.bind) && (t.repositoryName is repository.bind)) .sortBy(_.labelName asc) .list def getLabel(owner: String, repository: String, labelId: Int): Option[Label] = Query(Labels) - .filter(l => (l.userName is owner.bind) && (l.repositoryName is repository.bind) && (l.labelId is labelId.bind)) + .filter(t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind)) .firstOption def createLabel(owner: String, repository: String, labelName: String, color: String): Unit = @@ -26,19 +23,17 @@ trait LabelsService { def updateLabel(owner: String, repository: String, labelId: Int, labelName: String, color: String): Unit = Query(Labels) - .filter { l => (l.userName is owner.bind) && (l.repositoryName is repository.bind) && (l.labelId is labelId.bind)} - .map { l => l.labelName ~ l.color } + .filter { t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind)} + .map { t => t.labelName ~ t.color } .update (labelName, color) def deleteLabel(owner: String, repository: String, labelId: Int): Unit = { - // TODO delete ISSUE_LABEL -// Query(Issues) -// .filter { i => (i.userName is owner.bind) && (i.repositoryName is repository.bind) && (i.milestoneId is milestoneId.bind)} -// .map { i => i.milestoneId.? } -// .update(None) + Query(IssueLabels) + .filter { t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind)} + .delete Query(Labels) - .filter { i => (i.userName is owner.bind) && (i.repositoryName is repository.bind) && (i.labelId is labelId.bind)} + .filter { t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind)} .delete }