aboutsummaryrefslogtreecommitdiffstats
path: root/models/star.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-10-13 02:01:57 +0200
committerGitHub <noreply@github.com>2020-10-12 20:01:57 -0400
commitf4ffe8ed54cc49b8c0ca20a8aa1db6732f39a8a0 (patch)
treed731013c3489f8deda0a2c81ad4455249e9793c4 /models/star.go
parentf2858600af811c584c82b45efbf343b53821575b (diff)
downloadgitea-f4ffe8ed54cc49b8c0ca20a8aa1db6732f39a8a0.tar.gz
gitea-f4ffe8ed54cc49b8c0ca20a8aa1db6732f39a8a0.zip
Save TimeStamps for Star, Label, Follow, Watch and Collaboration to Database (#13124)
* Add timestamps to Star, Label, LanguageStat, Follow, Watch and Collaboration * Star do not need updated * LanguageStat do not need update (they wont change) * fix unit-test
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
}