Added update query for correct topics count
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
This commit is contained in:
parent
7ee9774cea
commit
0ceee66fee
|
|
@ -60,7 +60,7 @@ func reformatAndRemoveIncorrectTopics(x *xorm.Engine) (err error) {
|
||||||
if models.ValidateTopic(topic.Name) {
|
if models.ValidateTopic(topic.Name) {
|
||||||
unifiedTopic := Topic{Name:topic.Name}
|
unifiedTopic := Topic{Name:topic.Name}
|
||||||
exists, err := sess.Get(&unifiedTopic)
|
exists, err := sess.Get(&unifiedTopic)
|
||||||
log.Info("Exists topic with the name %q? %v id = %v", topic.Name, exists, unifiedTopic.ID)
|
log.Info("Exists topic with the name %q? %v, id = %v", topic.Name, exists, unifiedTopic.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -72,6 +72,12 @@ func reformatAndRemoveIncorrectTopics(x *xorm.Engine) (err error) {
|
||||||
topic.ID, topic.ID, unifiedTopic.ID).Update(&models.RepoTopic{TopicID:unifiedTopic.ID}); err != nil {
|
topic.ID, topic.ID, unifiedTopic.ID).Update(&models.RepoTopic{TopicID:unifiedTopic.ID}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.Info("Updating topic `repo_count` field")
|
||||||
|
if _, err := sess.Exec(
|
||||||
|
"UPDATE topic SET repo_count = (SELECT COUNT(*) FROM repo_topic WHERE topic_id = ? GROUP BY topic_id) WHERE id = ?",
|
||||||
|
unifiedTopic.ID, unifiedTopic.ID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Info("Updating topic: id = %v, name = %q", topic.ID, topic.Name)
|
log.Info("Updating topic: id = %v, name = %q", topic.ID, topic.Name)
|
||||||
if _, err := sess.Table("topic").ID(topic.ID).
|
if _, err := sess.Table("topic").ID(topic.ID).
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user