add feed endpoint for wall

This commit is contained in:
Brad Rydzewski 2015-08-18 16:09:27 -07:00
parent b370592f25
commit 1cc2e3d4d6
4 changed files with 20 additions and 2 deletions

View file

@ -142,6 +142,7 @@ func main() {
user.GET("", server.GetUserCurr) user.GET("", server.GetUserCurr)
user.PATCH("", server.PutUserCurr) user.PATCH("", server.PutUserCurr)
user.GET("/feed", server.GetUserFeed)
user.GET("/repos", server.GetUserRepos) user.GET("/repos", server.GetUserRepos)
user.GET("/tokens", server.GetUserTokens) user.GET("/tokens", server.GetUserTokens)
user.POST("/tokens", server.PostToken) user.POST("/tokens", server.PostToken)

View file

@ -59,6 +59,23 @@ func GetUserRepos(c *gin.Context) {
} }
} }
// GetUserFeed accepts a request to get the currently
// authenticated user's build feed from the datastore,
// encoded and returned in JSON format.
//
// GET /api/user/feed
//
func GetUserFeed(c *gin.Context) {
store := ToDatastore(c)
user := ToUser(c)
feed, err := store.UserFeed(user, 25, 0)
if err != nil {
c.Fail(400, err)
} else {
c.JSON(200, &feed)
}
}
// GetUserTokens accepts a request to get the currently // GetUserTokens accepts a request to get the currently
// authenticated user's token list from the datastore, // authenticated user's token list from the datastore,
// encoded and returned in JSON format. // encoded and returned in JSON format.

View file

@ -98,7 +98,7 @@ func scanRepoCommits(rows *sql.Rows) ([]*types.RepoCommit, error) {
&v.Name, &v.Name,
&v.FullName, &v.FullName,
&v.Number, &v.Number,
&v.State, &v.Status,
&v.Started, &v.Started,
&v.Finished, &v.Finished,
) )

View file

@ -51,7 +51,7 @@ type RepoCommit struct {
Name string `json:"name"` Name string `json:"name"`
FullName string `json:"full_name"` FullName string `json:"full_name"`
Number int `json:"number"` Number int `json:"number"`
State string `json:"state"` Status string `json:"status"`
Started int64 `json:"started_at"` Started int64 `json:"started_at"`
Finished int64 `json:"finished_at"` Finished int64 `json:"finished_at"`
} }