| @@ -9,6 +9,10 @@ class CompareController < ApplicationController | |||||
| load_compare_params | load_compare_params | ||||
| compare | compare | ||||
| @merge_status, @merge_message = get_merge_message | @merge_status, @merge_message = get_merge_message | ||||
| @page_size = page_size <= 0 ? 1 : page_size | |||||
| @page_limit = page_limit <=0 ? 15 : page_limit | |||||
| @page_offset = (@page_size -1) * @page_limit | |||||
| Rails.logger.info("+========#{@page_size}-#{@page_limit}-#{@page_offset}") | |||||
| end | end | ||||
| private | private | ||||
| @@ -53,4 +57,12 @@ class CompareController < ApplicationController | |||||
| def gitea_compare(base, head) | def gitea_compare(base, head) | ||||
| Gitea::Repository::Commits::CompareService.call(@owner.login, @project.identifier, Addressable::URI.escape(base), Addressable::URI.escape(head), current_user.gitea_token) | Gitea::Repository::Commits::CompareService.call(@owner.login, @project.identifier, Addressable::URI.escape(base), Addressable::URI.escape(head), current_user.gitea_token) | ||||
| end | end | ||||
| def page_size | |||||
| params.fetch(:page, 1).to_i | |||||
| end | |||||
| def page_limit | |||||
| params.fetch(:limit, 15).to_i | |||||
| end | |||||
| end | end | ||||
| @@ -36,7 +36,6 @@ module RepositoriesHelper | |||||
| end | end | ||||
| def render_cache_commit_author(author_json) | def render_cache_commit_author(author_json) | ||||
| Rails.logger.info author_json['Email'] | |||||
| if author_json["name"].present? && author_json["email"].present? | if author_json["name"].present? && author_json["email"].present? | ||||
| return find_user_in_redis_cache(author_json['name'], author_json['email']) | return find_user_in_redis_cache(author_json['name'], author_json['email']) | ||||
| end | end | ||||
| @@ -1,7 +1,7 @@ | |||||
| json.commits_count @compare_result['Commits']&.size | |||||
| json.commits_count @compare_result['CommitsCount'] | |||||
| # json.commits @compare_result['Commits'], partial: 'pull_requests/commit', as: :commit | # json.commits @compare_result['Commits'], partial: 'pull_requests/commit', as: :commit | ||||
| json.commits do | json.commits do | ||||
| json.array! @compare_result['Commits'] do |commit| | |||||
| json.array! @compare_result['Commits'][@page_offset...(@page_offset + @page_limit)] do |commit| | |||||
| json.author do | json.author do | ||||
| json.partial! 'repositories/commit_author', locals: { user: render_cache_commit_author(commit['Committer']), name: commit['Committer']['Name'] } | json.partial! 'repositories/commit_author', locals: { user: render_cache_commit_author(commit['Committer']), name: commit['Committer']['Name'] } | ||||
| end | end | ||||