Skip to content

Commit

Permalink
Remove unnecessary functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Jun 8, 2021
1 parent 175ec75 commit 818dd7d
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions models/issue_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,36 +779,3 @@ func deleteLabelsByRepoID(sess Engine, repoID int64) error {
_, err := sess.Delete(&Label{RepoID: repoID})
return err
}

// CountWrongLabels counts wrong data in issue_label and label
func CountWrongLabels() (int64, int64, error) {
wrongLabels, err := x.Where("repo_id > 0 and repo_id not in (select id from repository)").Count(new(Label))
if err != nil {
return 0, 0, err
}

wrongIssueLabels, err := x.Where("label_id IN (select id from label where repo_id > 0 and repo_id not in (select id from repository))").Count(new(IssueLabel))
if err != nil {
return 0, 0, err
}

return wrongLabels, wrongIssueLabels, nil
}

// FixWrongLabels fix wrong data in label
func FixWrongLabels() (int64, error) {
res, err := x.Exec("DELETE FROM label WHERE repo_id > 0 and repo_id not in (select id from repository)")
if err != nil {
return 0, err
}
return res.RowsAffected()
}

// FixWrongIssueLables fix wrong label data
func FixWrongIssueLables() (int64, error) {
res, err := x.Exec("DELETE FROM issue_label WHERE label_id in (select id FROM label WHERE repo_id > 0 and repo_id not in (select id from repository))")
if err != nil {
return 0, err
}
return res.RowsAffected()
}

0 comments on commit 818dd7d

Please sign in to comment.