Browse Source

新增:标签列表返回总数

pull/313/head
yystopf 3 years ago
parent
commit
3b15dd84fc
2 changed files with 6 additions and 1 deletions
  1. +4
    -0
      app/controllers/repositories_controller.rb
  2. +2
    -1
      app/views/repositories/tags.json.jbuilder

+ 4
- 0
app/controllers/repositories_controller.rb View File

@@ -152,6 +152,10 @@ class RepositoriesController < ApplicationController
@tags = result.is_a?(Hash) && result.key?(:status) ? [] : result @tags = result.is_a?(Hash) && result.key?(:status) ? [] : result
else else
name_result = Gitea::Repository::Tags::ListNameService.call(@owner, @project.identifier, params[:name])
@tag_names = result.is_a?(Hash) && result.key?(:status) ? [] : name_result
result = Gitea::Repository::Tags::ListService.call(current_user&.gitea_token, @owner.login, @project.identifier, {page: params[:page], limit: params[:limit]}) result = Gitea::Repository::Tags::ListService.call(current_user&.gitea_token, @owner.login, @project.identifier, {page: params[:page], limit: params[:limit]})
@tags = result.is_a?(Hash) && result.key?(:status) ? [] : result @tags = result.is_a?(Hash) && result.key?(:status) ? [] : result


+ 2
- 1
app/views/repositories/tags.json.jbuilder View File

@@ -1,4 +1,5 @@
json.array! @tags do |tag|
json.total_count @tag_names.present? ? @tag_names.count : @tags.count
json.tags @tags do |tag|
if tag.present? && tag.is_a?(Hash) if tag.present? && tag.is_a?(Hash)
json.name tag['name'] json.name tag['name']
json.id tag['id'] json.id tag['id']


Loading…
Cancel
Save