|
|
|
@@ -1,11 +1,13 @@ |
|
|
|
class Gitea::Repository::Contributors::GetService < Gitea::ClientService |
|
|
|
attr_reader :owner, :repo_name, :page, :limit |
|
|
|
attr_reader :owner, :repo_name, :page, :limit, :q_name, :q_email |
|
|
|
|
|
|
|
def initialize(owner, repo_name, params) |
|
|
|
@owner = owner |
|
|
|
@repo_name = repo_name |
|
|
|
@page = params[:page] || 1 |
|
|
|
@limit = params[:limit] || 20 |
|
|
|
@q_name = params[:q_name] || "" |
|
|
|
@q_email = params[:q_email] || "" |
|
|
|
end |
|
|
|
|
|
|
|
def call |
|
|
|
@@ -15,7 +17,7 @@ class Gitea::Repository::Contributors::GetService < Gitea::ClientService |
|
|
|
|
|
|
|
private |
|
|
|
def params |
|
|
|
Hash.new.merge(token: owner.gitea_token, page: page, limit: limit) |
|
|
|
Hash.new.merge(token: owner.gitea_token, page: page, limit: limit, q_name: q_name, q_email: q_email) |
|
|
|
end |
|
|
|
|
|
|
|
def url |
|
|
|
@@ -29,7 +31,8 @@ class Gitea::Repository::Contributors::GetService < Gitea::ClientService |
|
|
|
headers = response.headers.to_hash |
|
|
|
body = JSON.parse(response.body) |
|
|
|
total_count = headers["x-total"] |
|
|
|
result.merge(total_count: total_count.to_i, body: body) |
|
|
|
total_contributions = headers["x-total-contributions"] |
|
|
|
result.merge(total_count: total_count.to_i, total_contributions: total_contributions.to_i, body: body) |
|
|
|
else |
|
|
|
nil |
|
|
|
# {status: -1, message: "#{body['message']}"} |
|
|
|
|