mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 22:45:51 +01:00
Fix services to use shortcut method for primary key and foreign keys.
This commit is contained in:
@@ -8,33 +8,21 @@ import model._
|
||||
trait LabelsService {
|
||||
|
||||
def getLabels(owner: String, repository: String): List[Label] =
|
||||
Query(Labels)
|
||||
.filter(t => (t.userName is owner.bind) && (t.repositoryName is repository.bind))
|
||||
.sortBy(_.labelName asc)
|
||||
.list
|
||||
Query(Labels).filter(_.byRepository(owner, repository)).sortBy(_.labelName asc).list
|
||||
|
||||
def getLabel(owner: String, repository: String, labelId: Int): Option[Label] =
|
||||
Query(Labels)
|
||||
.filter(t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind))
|
||||
.firstOption
|
||||
Query(Labels).filter(_.byPrimaryKey(owner, repository, labelId)).firstOption
|
||||
|
||||
def createLabel(owner: String, repository: String, labelName: String, color: String): Unit =
|
||||
Labels.ins insert (owner, repository, labelName, color)
|
||||
|
||||
def updateLabel(owner: String, repository: String, labelId: Int, labelName: String, color: String): Unit =
|
||||
Query(Labels)
|
||||
.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)
|
||||
Query(Labels).filter(_.byPrimaryKey(owner, repository, labelId)).map(t => t.labelName ~ t.color)
|
||||
.update(labelName, color)
|
||||
|
||||
def deleteLabel(owner: String, repository: String, labelId: Int): Unit = {
|
||||
Query(IssueLabels)
|
||||
.filter { t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind)}
|
||||
.delete
|
||||
|
||||
Query(Labels)
|
||||
.filter { t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind)}
|
||||
.delete
|
||||
Query(IssueLabels).filter(_.byLabel(owner, repository, labelId)).delete
|
||||
Query(Labels).filter(_.byPrimaryKey(owner, repository, labelId)).delete
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user