Wall feed

This commit is contained in:
Scott Ferguson
2014-11-07 10:04:08 -06:00
parent 9b2bc91411
commit 44518e2015
4 changed files with 76 additions and 1 deletions

View File

@@ -56,6 +56,14 @@ func (db *Commitstore) GetCommitListUser(user *model.User) ([]*model.CommitRepo,
return commits, err
}
// GetCommitListActivity retrieves an ungrouped list of latest commits
// from the datastore accessible to the specified user.
func (db *Commitstore) GetCommitListActivity(user *model.User) ([]*model.CommitRepo, error) {
var commits []*model.CommitRepo
var err = meddler.QueryAll(db, &commits, rebind(commitListActivityQuery), user.ID)
return commits, err
}
// PostCommit saves a commit in the datastore.
func (db *Commitstore) PostCommit(commit *model.Commit) error {
if commit.Created == 0 {
@@ -97,7 +105,7 @@ WHERE commit_id = ?
`
// SQL query to retrieve the latest Commits accessible
// to ta specific user account
// to a specific user account
const commitListUserQuery = `
SELECT r.repo_remote, r.repo_host, r.repo_owner, r.repo_name, c.*
FROM
@@ -117,6 +125,21 @@ WHERE c.repo_id = r.repo_id
) ORDER BY c.commit_created DESC LIMIT 5;
`
// SQL query to retrieve the ungrouped, latest Commits
// accessible to a specific user account
const commitListActivityQuery = `
SELECT r.repo_remote, r.repo_host, r.repo_owner, r.repo_name, c.*
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 = ?
ORDER BY c.commit_created DESC
LIMIT 20
`
// SQL query to retrieve the latest Commits across all branches.
const commitListQuery = `
SELECT *