mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-16 11:00:02 +02:00
Improvements for supporting UI Location (#3146)
* improvements for supporting UI Location * improved the comment
This commit is contained in:
parent
b6d2243ac0
commit
f94c1b3943
7 changed files with 28 additions and 25 deletions
|
@ -600,20 +600,16 @@ type DeployKey struct {
|
|||
Fingerprint string
|
||||
Content string `xorm:"-"`
|
||||
|
||||
Created time.Time `xorm:"-"`
|
||||
CreatedUnix int64 `xorm:"created"`
|
||||
Updated time.Time `xorm:"-"`
|
||||
UpdatedUnix int64 `xorm:"updated"`
|
||||
HasRecentActivity bool `xorm:"-"`
|
||||
HasUsed bool `xorm:"-"`
|
||||
CreatedUnix util.TimeStamp `xorm:"created"`
|
||||
UpdatedUnix util.TimeStamp `xorm:"updated"`
|
||||
HasRecentActivity bool `xorm:"-"`
|
||||
HasUsed bool `xorm:"-"`
|
||||
}
|
||||
|
||||
// AfterLoad is invoked from XORM after setting the values of all fields of this object.
|
||||
func (key *DeployKey) AfterLoad() {
|
||||
key.Created = time.Unix(key.CreatedUnix, 0).Local()
|
||||
key.Updated = time.Unix(key.UpdatedUnix, 0).Local()
|
||||
key.HasUsed = key.Updated.After(key.Created)
|
||||
key.HasRecentActivity = key.Updated.Add(7 * 24 * time.Hour).After(time.Now())
|
||||
key.HasUsed = key.UpdatedUnix > key.CreatedUnix
|
||||
key.HasRecentActivity = key.UpdatedUnix.AddDuration(7*24*time.Hour) > util.TimeStampNow()
|
||||
}
|
||||
|
||||
// GetContent gets associated public key content.
|
||||
|
@ -740,6 +736,12 @@ func GetDeployKeyByRepo(keyID, repoID int64) (*DeployKey, error) {
|
|||
return key, nil
|
||||
}
|
||||
|
||||
// UpdateDeployKeyCols updates deploy key information in the specified columns.
|
||||
func UpdateDeployKeyCols(key *DeployKey, cols ...string) error {
|
||||
_, err := x.ID(key.ID).Cols(cols...).Update(key)
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateDeployKey updates deploy key information.
|
||||
func UpdateDeployKey(key *DeployKey) error {
|
||||
_, err := x.ID(key.ID).AllCols().Update(key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue