add feed endpoint for wall
This commit is contained in:
parent
b370592f25
commit
1cc2e3d4d6
4 changed files with 20 additions and 2 deletions
|
@ -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)
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
|
@ -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"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue