diff --git a/cmd/drone-server/drone.go b/cmd/drone-server/drone.go index aecd8f41..45163a71 100644 --- a/cmd/drone-server/drone.go +++ b/cmd/drone-server/drone.go @@ -142,6 +142,7 @@ func main() { user.GET("", server.GetUserCurr) user.PATCH("", server.PutUserCurr) + user.GET("/feed", server.GetUserFeed) user.GET("/repos", server.GetUserRepos) user.GET("/tokens", server.GetUserTokens) user.POST("/tokens", server.PostToken) diff --git a/pkg/server/user.go b/pkg/server/user.go index 67d4d478..6347a197 100644 --- a/pkg/server/user.go +++ b/pkg/server/user.go @@ -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 // authenticated user's token list from the datastore, // encoded and returned in JSON format. diff --git a/pkg/store/builtin/user.go b/pkg/store/builtin/user.go index cc7728df..261477ce 100644 --- a/pkg/store/builtin/user.go +++ b/pkg/store/builtin/user.go @@ -98,7 +98,7 @@ func scanRepoCommits(rows *sql.Rows) ([]*types.RepoCommit, error) { &v.Name, &v.FullName, &v.Number, - &v.State, + &v.Status, &v.Started, &v.Finished, ) diff --git a/pkg/types/repo.go b/pkg/types/repo.go index 001a2ebf..d028e761 100644 --- a/pkg/types/repo.go +++ b/pkg/types/repo.go @@ -51,7 +51,7 @@ type RepoCommit struct { Name string `json:"name"` FullName string `json:"full_name"` Number int `json:"number"` - State string `json:"state"` + Status string `json:"status"` Started int64 `json:"started_at"` Finished int64 `json:"finished_at"` }