Added query solution for duplicates
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
This commit is contained in:
parent
8fee5d3f64
commit
9141482afd
|
|
@ -129,7 +129,7 @@ func reformatAndRemoveIncorrectTopics(x *xorm.Engine) (err error) {
|
|||
}
|
||||
log.Info("Updating 'topics' field for repository with id = %v", repoID)
|
||||
if _, err := sess.ID(repoID).Cols("topics").
|
||||
Update(&models.Repository{ID: repoID, Topics: topicNames}); err != nil {
|
||||
Update(&models.Repository{Topics: topicNames}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,6 +190,13 @@ func SaveTopics(repoID int64, topicNames ...string) error {
|
|||
}
|
||||
}
|
||||
|
||||
topicNames = topicNames[:0]
|
||||
if err := sess.Table("topic").Cols("name").
|
||||
Join("INNER", "repo_topic", "topic.id = repo_topic.topic_id").
|
||||
Where("repo_topic.repo_id = ?", repoID).Find(&topicNames); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := sess.ID(repoID).Cols("topics").Update(&Repository{
|
||||
Topics: topicNames,
|
||||
}); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user