aboutsummaryrefslogtreecommitdiffstats
path: root/models/star.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/star.go')
-rw-r--r--models/star.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/models/star.go b/models/star.go
index 4e84a6e4d5..2d9496caf5 100644
--- a/models/star.go
+++ b/models/star.go
@@ -4,11 +4,16 @@
package models
+import (
+ "code.gitea.io/gitea/modules/timeutil"
+)
+
// Star represents a starred repo by an user.
type Star struct {
- ID int64 `xorm:"pk autoincr"`
- UID int64 `xorm:"UNIQUE(s)"`
- RepoID int64 `xorm:"UNIQUE(s)"`
+ ID int64 `xorm:"pk autoincr"`
+ UID int64 `xorm:"UNIQUE(s)"`
+ RepoID int64 `xorm:"UNIQUE(s)"`
+ CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
}
// StarRepo or unstar repository.
@@ -39,7 +44,7 @@ func StarRepo(userID, repoID int64, star bool) error {
return nil
}
- if _, err := sess.Delete(&Star{0, userID, repoID}); err != nil {
+ if _, err := sess.Delete(&Star{UID: userID, RepoID: repoID}); err != nil {
return err
}
if _, err := sess.Exec("UPDATE `repository` SET num_stars = num_stars - 1 WHERE id = ?", repoID); err != nil {
@@ -59,7 +64,7 @@ func IsStaring(userID, repoID int64) bool {
}
func isStaring(e Engine, userID, repoID int64) bool {
- has, _ := e.Get(&Star{0, userID, repoID})
+ has, _ := e.Get(&Star{UID: userID, RepoID: repoID})
return has
}