|
|
|
@@ -109,6 +109,24 @@ class Api::V1::Projects::SyncRepositoriesController < Api::V1::BaseController |
|
|
|
@sync_repository_branches = SyncRepositoryBranch.where(sync_repository_id: params[:sync_repository_ids].split(",")) |
|
|
|
@sync_repository_branches = @sync_repository_branches.ransack(gitlink_branch_name_or_external_branch_name_cont: params[:branch_name]).result if params[:branch_name].present? |
|
|
|
@group_sync_repository_branch = @sync_repository_branches.joins(:sync_repository).group("sync_repositories.type, sync_repository_branches.gitlink_branch_name, sync_repository_branches.external_branch_name").select("sync_repositories.type as type,max(sync_repository_branches.updated_at) as updated_at, sync_repository_branches.gitlink_branch_name, sync_repository_branches.external_branch_name").sort_by{|i|i.updated_at} |
|
|
|
@each_json = [] |
|
|
|
@group_sync_repository_branch.each do |item| |
|
|
|
branches = @sync_repository_branches.joins(:sync_repository).where(sync_repositories: {type: item.type}, gitlink_branch_name: item.gitlink_branch_name, external_branch_name: item.external_branch_name).order(updated_at: :desc) |
|
|
|
branch = branches.first |
|
|
|
@each_json << { |
|
|
|
gitlink_branch_name: item.gitlink_branch_name, |
|
|
|
external_branch_name: item.external_branch_name, |
|
|
|
type: branch&.sync_repository&.type, |
|
|
|
sync_time: branch.sync_time.present? ? branch.sync_time.strftime("%Y-%m-%d %H:%M:%S") : nil, |
|
|
|
sync_status: branch.sync_status, |
|
|
|
enable: branch.enable, |
|
|
|
enable_num: branch.enable ? 1 : 0, |
|
|
|
created_at: branch.created_at.to_i, |
|
|
|
reposync_branch_ids: branches.pluck(:reposync_branch_id) |
|
|
|
} |
|
|
|
end |
|
|
|
@each_json = @each_json.sort_by{|h| [-h[:enable_num], h[:created_at]]} |
|
|
|
render :json => {total_count: @group_sync_repository_branch.count, sync_repository_branches: @each_json} |
|
|
|
end |
|
|
|
|
|
|
|
def history |
|
|
|
|