Merge pull request #563 from bradrydzewski/master
set created & updated dates in database
This commit is contained in:
commit
b511fd2d32
3 changed files with 30 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
package database
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/drone/drone/shared/model"
|
"github.com/drone/drone/shared/model"
|
||||||
"github.com/russross/meddler"
|
"github.com/russross/meddler"
|
||||||
)
|
)
|
||||||
|
@ -56,11 +58,19 @@ func (db *Commitstore) GetCommitListUser(user *model.User) ([]*model.CommitRepo,
|
||||||
|
|
||||||
// PostCommit saves a commit in the datastore.
|
// PostCommit saves a commit in the datastore.
|
||||||
func (db *Commitstore) PostCommit(commit *model.Commit) error {
|
func (db *Commitstore) PostCommit(commit *model.Commit) error {
|
||||||
|
if commit.Created == 0 {
|
||||||
|
commit.Created = time.Now().UTC().Unix()
|
||||||
|
}
|
||||||
|
commit.Updated = time.Now().UTC().Unix()
|
||||||
return meddler.Save(db, commitTable, commit)
|
return meddler.Save(db, commitTable, commit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutCommit saves a commit in the datastore.
|
// PutCommit saves a commit in the datastore.
|
||||||
func (db *Commitstore) PutCommit(commit *model.Commit) error {
|
func (db *Commitstore) PutCommit(commit *model.Commit) error {
|
||||||
|
if commit.Created == 0 {
|
||||||
|
commit.Created = time.Now().UTC().Unix()
|
||||||
|
}
|
||||||
|
commit.Updated = time.Now().UTC().Unix()
|
||||||
return meddler.Save(db, commitTable, commit)
|
return meddler.Save(db, commitTable, commit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package database
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/drone/drone/shared/model"
|
"github.com/drone/drone/shared/model"
|
||||||
"github.com/russross/meddler"
|
"github.com/russross/meddler"
|
||||||
)
|
)
|
||||||
|
@ -39,11 +41,19 @@ func (db *Repostore) GetRepoList(user *model.User) ([]*model.Repo, error) {
|
||||||
|
|
||||||
// PostRepo saves a repo in the datastore.
|
// PostRepo saves a repo in the datastore.
|
||||||
func (db *Repostore) PostRepo(repo *model.Repo) error {
|
func (db *Repostore) PostRepo(repo *model.Repo) error {
|
||||||
|
if repo.Created == 0 {
|
||||||
|
repo.Created = time.Now().UTC().Unix()
|
||||||
|
}
|
||||||
|
repo.Updated = time.Now().UTC().Unix()
|
||||||
return meddler.Save(db, repoTable, repo)
|
return meddler.Save(db, repoTable, repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutRepo saves a repo in the datastore.
|
// PutRepo saves a repo in the datastore.
|
||||||
func (db *Repostore) PutRepo(repo *model.Repo) error {
|
func (db *Repostore) PutRepo(repo *model.Repo) error {
|
||||||
|
if repo.Created == 0 {
|
||||||
|
repo.Created = time.Now().UTC().Unix()
|
||||||
|
}
|
||||||
|
repo.Updated = time.Now().UTC().Unix()
|
||||||
return meddler.Save(db, repoTable, repo)
|
return meddler.Save(db, repoTable, repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package database
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/drone/drone/shared/model"
|
"github.com/drone/drone/shared/model"
|
||||||
"github.com/russross/meddler"
|
"github.com/russross/meddler"
|
||||||
)
|
)
|
||||||
|
@ -47,11 +49,19 @@ func (db *Userstore) GetUserList() ([]*model.User, error) {
|
||||||
|
|
||||||
// PostUser saves a User in the datastore.
|
// PostUser saves a User in the datastore.
|
||||||
func (db *Userstore) PostUser(user *model.User) error {
|
func (db *Userstore) PostUser(user *model.User) error {
|
||||||
|
if user.Created == 0 {
|
||||||
|
user.Created = time.Now().UTC().Unix()
|
||||||
|
}
|
||||||
|
user.Updated = time.Now().UTC().Unix()
|
||||||
return meddler.Save(db, userTable, user)
|
return meddler.Save(db, userTable, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutUser saves a user in the datastore.
|
// PutUser saves a user in the datastore.
|
||||||
func (db *Userstore) PutUser(user *model.User) error {
|
func (db *Userstore) PutUser(user *model.User) error {
|
||||||
|
if user.Created == 0 {
|
||||||
|
user.Created = time.Now().UTC().Unix()
|
||||||
|
}
|
||||||
|
user.Updated = time.Now().UTC().Unix()
|
||||||
return meddler.Save(db, userTable, user)
|
return meddler.Save(db, userTable, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue