diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-01-06 09:51:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-06 09:51:15 +0800 |
commit | 61306fa737f693c3b325d9a8da047ba0b939537e (patch) | |
tree | 91d85ffddf960a7cb64343ed47277027f9227110 /models/release.go | |
parent | 79d527195d98d74867a067ce93a4dace2b86d2bb (diff) | |
download | gitea-61306fa737f693c3b325d9a8da047ba0b939537e.tar.gz gitea-61306fa737f693c3b325d9a8da047ba0b939537e.zip |
Make releases faster than before and resolved #490 (#588)
* make releases faster than before and resolved #490
* fix comment
Diffstat (limited to 'models/release.go')
-rw-r--r-- | models/release.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/models/release.go b/models/release.go index 428b79e45f..28ba6c1d68 100644 --- a/models/release.go +++ b/models/release.go @@ -22,12 +22,12 @@ import ( // Release represents a release of repository. type Release struct { - ID int64 `xorm:"pk autoincr"` - RepoID int64 + ID int64 `xorm:"pk autoincr"` + RepoID int64 `xorm:"index unique(n)"` Repo *Repository `xorm:"-"` PublisherID int64 - Publisher *User `xorm:"-"` - TagName string + Publisher *User `xorm:"-"` + TagName string `xorm:"index unique(n)"` LowerTagName string Target string Title string @@ -213,6 +213,15 @@ func GetReleasesByRepoID(repoID int64, page, pageSize int) (rels []*Release, err return rels, err } +// GetReleasesByRepoIDAndNames returns a list of releases of repository accroding repoID and tagNames. +func GetReleasesByRepoIDAndNames(repoID int64, tagNames []string) (rels []*Release, err error) { + err = x. + Desc("created_unix"). + In("tag_name", tagNames). + Find(&rels, Release{RepoID: repoID}) + return rels, err +} + type releaseSorter struct { rels []*Release } |