summaryrefslogtreecommitdiffstats
path: root/routers/api/v1
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1')
-rw-r--r--routers/api/v1/org/team.go1
-rw-r--r--routers/api/v1/repo/issue_reaction.go7
-rw-r--r--routers/api/v1/repo/issue_subscription.go11
-rw-r--r--routers/api/v1/repo/status.go4
-rw-r--r--routers/api/v1/repo/tree.go1
-rw-r--r--routers/api/v1/repo/wiki.go2
-rw-r--r--routers/api/v1/user/star.go3
7 files changed, 22 insertions, 7 deletions
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index 074d6fd009..d39125b050 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -509,6 +509,7 @@ func GetTeamRepos(ctx *context.APIContext) {
}
repos[i] = convert.ToRepo(repo, access)
}
+ ctx.SetTotalCountHeader(int64(team.NumRepos))
ctx.JSON(http.StatusOK, repos)
}
diff --git a/routers/api/v1/repo/issue_reaction.go b/routers/api/v1/repo/issue_reaction.go
index d0ba8dac65..6184ea71f0 100644
--- a/routers/api/v1/repo/issue_reaction.go
+++ b/routers/api/v1/repo/issue_reaction.go
@@ -67,9 +67,9 @@ func GetIssueCommentReactions(ctx *context.APIContext) {
return
}
- reactions, err := models.FindCommentReactions(comment)
+ reactions, _, err := models.FindCommentReactions(comment)
if err != nil {
- ctx.Error(http.StatusInternalServerError, "FindIssueReactions", err)
+ ctx.Error(http.StatusInternalServerError, "FindCommentReactions", err)
return
}
_, err = reactions.LoadUsers(ctx.Repo.Repository)
@@ -285,7 +285,7 @@ func GetIssueReactions(ctx *context.APIContext) {
return
}
- reactions, err := models.FindIssueReactions(issue, utils.GetListOptions(ctx))
+ reactions, count, err := models.FindIssueReactions(issue, utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "FindIssueReactions", err)
return
@@ -305,6 +305,7 @@ func GetIssueReactions(ctx *context.APIContext) {
})
}
+ ctx.SetTotalCountHeader(count)
ctx.JSON(http.StatusOK, result)
}
diff --git a/routers/api/v1/repo/issue_subscription.go b/routers/api/v1/repo/issue_subscription.go
index ae7661cfab..ff305c4877 100644
--- a/routers/api/v1/repo/issue_subscription.go
+++ b/routers/api/v1/repo/issue_subscription.go
@@ -279,9 +279,16 @@ func GetIssueSubscribers(ctx *context.APIContext) {
return
}
apiUsers := make([]*api.User, 0, len(users))
- for i := range users {
- apiUsers[i] = convert.ToUser(users[i], ctx.User)
+ for _, v := range users {
+ apiUsers = append(apiUsers, convert.ToUser(v, ctx.User))
}
+ count, err := models.CountIssueWatchers(issue.ID)
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, "CountIssueWatchers", err)
+ return
+ }
+
+ ctx.SetTotalCountHeader(count)
ctx.JSON(http.StatusOK, apiUsers)
}
diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go
index 583b89dd7a..9d0fbbddad 100644
--- a/routers/api/v1/repo/status.go
+++ b/routers/api/v1/repo/status.go
@@ -253,7 +253,7 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
repo := ctx.Repo.Repository
- statuses, err := models.GetLatestCommitStatus(repo.ID, sha, utils.GetListOptions(ctx))
+ statuses, count, err := models.GetLatestCommitStatus(repo.ID, sha, utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLatestCommitStatus", fmt.Errorf("GetLatestCommitStatus[%s, %s]: %v", repo.FullName(), sha, err))
return
@@ -266,6 +266,6 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
combiStatus := convert.ToCombinedStatus(statuses, convert.ToRepo(repo, ctx.Repo.AccessMode))
- // TODO: ctx.SetTotalCountHeader(count)
+ ctx.SetTotalCountHeader(count)
ctx.JSON(http.StatusOK, combiStatus)
}
diff --git a/routers/api/v1/repo/tree.go b/routers/api/v1/repo/tree.go
index 2168a311d0..411d87d6c5 100644
--- a/routers/api/v1/repo/tree.go
+++ b/routers/api/v1/repo/tree.go
@@ -63,6 +63,7 @@ func GetTree(ctx *context.APIContext) {
if tree, err := files_service.GetTreeBySHA(ctx.Repo.Repository, sha, ctx.FormInt("page"), ctx.FormInt("per_page"), ctx.FormBool("recursive")); err != nil {
ctx.Error(http.StatusBadRequest, "", err.Error())
} else {
+ ctx.SetTotalCountHeader(int64(tree.TotalCount))
ctx.JSON(http.StatusOK, tree)
}
}
diff --git a/routers/api/v1/repo/wiki.go b/routers/api/v1/repo/wiki.go
index f8969067be..bef32f367b 100644
--- a/routers/api/v1/repo/wiki.go
+++ b/routers/api/v1/repo/wiki.go
@@ -323,6 +323,7 @@ func ListWikiPages(ctx *context.APIContext) {
pages = append(pages, convert.ToWikiPageMetaData(wikiName, c, ctx.Repo.Repository))
}
+ ctx.SetTotalCountHeader(int64(len(entries)))
ctx.JSON(http.StatusOK, pages)
}
@@ -432,6 +433,7 @@ func ListPageRevisions(ctx *context.APIContext) {
return
}
+ ctx.SetTotalCountHeader(commitsCount)
ctx.JSON(http.StatusOK, convert.ToWikiCommitList(commitsHistory, commitsCount))
}
diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go
index 14bc23b1c3..cc527d9213 100644
--- a/routers/api/v1/user/star.go
+++ b/routers/api/v1/user/star.go
@@ -67,7 +67,10 @@ func GetStarredRepos(ctx *context.APIContext) {
repos, err := getStarredRepos(user, private, utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "getStarredRepos", err)
+ return
}
+
+ ctx.SetTotalCountHeader(int64(user.NumStars))
ctx.JSON(http.StatusOK, &repos)
}