|
|
|
@ -224,6 +224,24 @@ func DeleteOrphanedLabels() error { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// CountOrphanedIssueLabels return count of IssueLabels witch have no label behind anymore
|
|
|
|
|
func CountOrphanedIssueLabels() (int64, error) { |
|
|
|
|
return x.Table("issue_label"). |
|
|
|
|
Join("LEFT", "label", "issue_label.label_id = label.id"). |
|
|
|
|
Where(builder.IsNull{"label.id"}).Count() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// DeleteOrphanedIssueLabels delete IssueLabels witch have no label behind anymore
|
|
|
|
|
func DeleteOrphanedIssueLabels() error { |
|
|
|
|
|
|
|
|
|
_, err := x.In("id", builder.Select("issue_label.id").From("issue_label"). |
|
|
|
|
Join("LEFT", "label", "issue_label.label_id = label.id"). |
|
|
|
|
Where(builder.IsNull{"label.id"})). |
|
|
|
|
Delete(IssueLabel{}) |
|
|
|
|
|
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// CountOrphanedIssues count issues without a repo
|
|
|
|
|
func CountOrphanedIssues() (int64, error) { |
|
|
|
|
return x.Table("issue"). |
|
|
|
|