1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-06-12 21:47:35 +02:00

hooked up commit feed for user dashboard

This commit is contained in:
Brad Rydzewski
2014-10-01 11:29:23 -07:00
parent 17e5b76ec8
commit e725abe204
4 changed files with 93 additions and 47 deletions

View File

@ -48,8 +48,10 @@ func (db *Commitstore) GetCommitList(repo *model.Repo) ([]*model.Commit, error)
// GetCommitListUser retrieves a list of latest commits
// from the datastore accessible to the specified user.
func (db *Commitstore) GetCommitListUser(user *model.User) ([]*model.Commit, error) {
return nil, nil
func (db *Commitstore) GetCommitListUser(user *model.User) ([]*model.CommitRepo, error) {
var commits []*model.CommitRepo
var err = meddler.QueryAll(db, &commits, rebind(commitListUserQuery), user.ID)
return commits, err
}
// PostCommit saves a commit in the datastore.
@ -84,6 +86,28 @@ DELETE FROM commits
WHERE commit_id = ?
`
// SQL query to retrieve the latest Commits accessible
// to ta specific user account
const commitListUserQuery = `
SELECT r.repo_remote, r.repo_host, r.repo_owner, r.repo_name, c.*
FROM
commits c
,repos r
WHERE c.repo_id = r.repo_id
AND c.commit_id IN (
SELECT max(c.commit_id)
FROM
commits c
,repos r
,perms p
WHERE c.repo_id = r.repo_id
AND r.repo_id = p.repo_id
AND p.user_id = ?
AND c.commit_status NOT IN ('Started', 'Pending')
GROUP BY r.repo_id
) ORDER BY c.commit_created DESC LIMIT 5;
`
// SQL query to retrieve the latest Commits across all branches.
const commitListQuery = `
SELECT *