|
|
|
|
|
|
|
|
if !LabelColorPattern.MatchString(l.Color) { |
|
|
if !LabelColorPattern.MatchString(l.Color) { |
|
|
return fmt.Errorf("bad color code: %s", l.Color) |
|
|
return fmt.Errorf("bad color code: %s", l.Color) |
|
|
} |
|
|
} |
|
|
return updateLabel(x, l) |
|
|
|
|
|
|
|
|
return updateLabelCols(x, l, "name", "description", "color") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// DeleteLabel delete a label |
|
|
// DeleteLabel delete a label |
|
|
|
|
|
|
|
|
return getLabelsByIssueID(x, issueID) |
|
|
return getLabelsByIssueID(x, issueID) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func updateLabel(e Engine, l *Label) error { |
|
|
|
|
|
|
|
|
func updateLabelCols(e Engine, l *Label, cols ...string) error { |
|
|
_, err := e.ID(l.ID). |
|
|
_, err := e.ID(l.ID). |
|
|
SetExpr("num_issues", |
|
|
SetExpr("num_issues", |
|
|
builder.Select("count(*)").From("issue_label"). |
|
|
builder.Select("count(*)").From("issue_label"). |
|
|
|
|
|
|
|
|
"issue.is_closed": true, |
|
|
"issue.is_closed": true, |
|
|
}), |
|
|
}), |
|
|
). |
|
|
). |
|
|
AllCols().Update(l) |
|
|
|
|
|
|
|
|
Cols(cols...).Update(l) |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return updateLabel(e, label) |
|
|
|
|
|
|
|
|
return updateLabelCols(e, label, "num_issues", "num_closed_issue") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// NewIssueLabel creates a new issue-label relation. |
|
|
// NewIssueLabel creates a new issue-label relation. |
|
|
|
|
|
|
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return updateLabel(e, label) |
|
|
|
|
|
|
|
|
return updateLabelCols(e, label, "num_issues", "num_closed_issue") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// DeleteIssueLabel deletes issue-label relation. |
|
|
// DeleteIssueLabel deletes issue-label relation. |