diff options
author | Bwko <bouwko@gmail.com> | 2016-11-24 22:02:54 +0100 |
---|---|---|
committer | Bwko <bouwko@gmail.com> | 2016-11-24 22:02:54 +0100 |
commit | ece19f4a5e948a1e0fab7a1a0d64f39d5ad8d9d3 (patch) | |
tree | 04e2ab26f22ae512bfcc6218f392566d70e3f6b2 /models | |
parent | 21e8deed897a99fc86cd6506ce1bf4a9a8c07fba (diff) | |
download | gitea-ece19f4a5e948a1e0fab7a1a0d64f39d5ad8d9d3.tar.gz gitea-ece19f4a5e948a1e0fab7a1a0d64f39d5ad8d9d3.zip |
Lint models/release.go
Diffstat (limited to 'models')
-rw-r--r-- | models/release.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/models/release.go b/models/release.go index a60376d978..c047b2f557 100644 --- a/models/release.go +++ b/models/release.go @@ -38,12 +38,14 @@ type Release struct { CreatedUnix int64 } +// BeforeInsert is invoked from XORM before inserting an object of this type. func (r *Release) BeforeInsert() { if r.CreatedUnix == 0 { r.CreatedUnix = time.Now().Unix() } } +// AfterSet is invoked from XORM after setting the value of a field of this object. func (r *Release) AfterSet(colName string, _ xorm.Cell) { switch colName { case "created_unix": @@ -151,15 +153,15 @@ func GetReleasesByRepoID(repoID int64, page, pageSize int) (rels []*Release, err return rels, err } -type ReleaseSorter struct { +type releaseSorter struct { rels []*Release } -func (rs *ReleaseSorter) Len() int { +func (rs *releaseSorter) Len() int { return len(rs.rels) } -func (rs *ReleaseSorter) Less(i, j int) bool { +func (rs *releaseSorter) Less(i, j int) bool { diffNum := rs.rels[i].NumCommits - rs.rels[j].NumCommits if diffNum != 0 { return diffNum > 0 @@ -167,13 +169,13 @@ func (rs *ReleaseSorter) Less(i, j int) bool { return rs.rels[i].Created.After(rs.rels[j].Created) } -func (rs *ReleaseSorter) Swap(i, j int) { +func (rs *releaseSorter) Swap(i, j int) { rs.rels[i], rs.rels[j] = rs.rels[j], rs.rels[i] } // SortReleases sorts releases by number of commits and created time. func SortReleases(rels []*Release) { - sorter := &ReleaseSorter{rels: rels} + sorter := &releaseSorter{rels: rels} sort.Sort(sorter) } |