diff --git a/README.md b/README.md index 08e1b0a2d..1cf3a9c97 100644 --- a/README.md +++ b/README.md @@ -915,6 +915,8 @@ http://localhost:3000/api/18816895620/mirror_demo | jq |praises_count |int|点赞数量| |forked_count |int|fork数量| |watchers_count |int|关注数量| +|branches_count |int|分支数量| +|commits_count |int|总提交记录数量| |author |object|提交用户| |-- login |string|用户名称| |-- image_url |string|用户头像| @@ -927,6 +929,8 @@ http://localhost:3000/api/18816895620/mirror_demo | jq "praises_count": 0, "forked_count": 0, "watchers_count": 0, + "branches_count": 4, + "commits_count": 81, "author": { "name": "18816895620", "image_url": "avatars/User/b" diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 8e9412123..ef0231c3a 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -3,6 +3,8 @@ class RepositoriesController < ApplicationController before_action :find_user, :find_repository, :authorizate! def show + @branches_count = Gitea::Repository::BranchesService.new(@user, @repo.identifier).call.size + @commits_count = Gitea::Repository::Commits::ListService.new(@user, @repo.identifier).call[:total_count] end def entries diff --git a/app/views/repositories/show.json.jbuilder b/app/views/repositories/show.json.jbuilder index a515a9509..c2bb14637 100644 --- a/app/views/repositories/show.json.jbuilder +++ b/app/views/repositories/show.json.jbuilder @@ -2,4 +2,6 @@ json.identifier @repo.identifier json.praises_count @repo.project.praises_count json.forked_count @repo.project.forked_count json.watchers_count @repo.project.watchers_count +json.branches_count @branches_count +json.commits_count @commits_count json.partial! 'author', locals: { user: @repo.user }