aboutsummaryrefslogtreecommitdiffstats
path: root/models/topic.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/topic.go')
-rw-r--r--models/topic.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/models/topic.go b/models/topic.go
index 247aac5fff..678795a3db 100644
--- a/models/topic.go
+++ b/models/topic.go
@@ -26,7 +26,7 @@ var topicPattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]*$`)
// Topic represents a topic of repositories
type Topic struct {
ID int64
- Name string `xorm:"unique"`
+ Name string `xorm:"UNIQUE"`
RepoCount int
CreatedUnix util.TimeStamp `xorm:"INDEX created"`
UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
@@ -34,8 +34,8 @@ type Topic struct {
// RepoTopic represents associated repositories and topics
type RepoTopic struct {
- RepoID int64 `xorm:"unique(s)"`
- TopicID int64 `xorm:"unique(s)"`
+ RepoID int64 `xorm:"UNIQUE(s)"`
+ TopicID int64 `xorm:"UNIQUE(s)"`
}
// ErrTopicNotExist represents an error that a topic is not exist
@@ -190,10 +190,10 @@ func SaveTopics(repoID int64, topicNames ...string) error {
}
}
- topicNames = topicNames[:0]
+ topicNames = make([]string, 0, 25)
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 {
+ Join("INNER", "repo_topic", "repo_topic.topic_id = topic.id").
+ Where("repo_topic.repo_id = ?", repoID).Desc("topic.repo_count").Find(&topicNames); err != nil {
return err
}