json.partial! "commons/success"
json.open_count @open_issues.size
json.close_count @close_issues.size
json.merged_issues_size @merged_issues.size
json.search_count @issues_size
json.limit @limit
json.user_admin_or_member @user_admin_or_member
json.user_admin_or_developer @user_admin_or_developer
json.project_name @project.name
json.project_author @project.owner.try(:login)
json.project_author_name @project.owner.try(:show_real_name)
json.has_created_pull_requests @project.pull_requests.size > 0
json.disable_pr_vew @project.pr_view_admin? && !@project.manager?(current_user)
json.pr_need @project.owner.class == User ? false : @project.owner&.cla.try(:pr_need)

json.issues do
  json.array! @issues.to_a do |issue|
    pr = issue.pull_request
    json.pull_request_id pr.id
    json.pull_request_number pr.gitea_number
    json.pull_request_status pr.status
    json.pull_request_head pr.head 
    json.pull_request_base pr.base
    json.pull_request_staus pr.status == 1 ? "merged" : (pr.status == 2 ? "closed" : "open")
    json.is_original pr.is_original
    json.fork_project_id pr.fork_project_id
    json.fork_project_identifier pr.fork_project.present? ? pr&.fork_project&.identifier : pr.fork_project_identifier
    json.fork_project_user pr.fork_project.present? ? pr&.fork_project&.owner.try(:login) : pr.fork_project_owner
    json.fork_project_user_name pr.fork_project.present? ? pr&.fork_project&.owner.try(:show_real_name) : User.find_by(login: pr.fork_project_owner).try(:show_real_name)
    json.reviewers pr.reviewers.pluck(:login)

    json.id issue.id
    json.name issue.subject
    json.pr_time time_from_now(pr.status == 1 ? pr.updated_at : issue.updated_on)
    json.pr_time_at pr.status == 1 ? pr.updated_at : issue.updated_on
    json.pr_full_time pr.status == 1 ? pr.updated_at : issue.updated_on
    json.pr_created_unix pr.created_at.to_i
    json.assign_user_name issue.get_assign_user.try(:show_real_name)
    json.assign_user_login issue.get_assign_user.try(:login)
    json.author_name issue.user.blank?? "已注销": issue.user.show_real_name
    json.author_login issue.user.try(:login)
    json.avatar_url issue.user.blank?? "images/account/del.svg" : url_to_avatar(issue.user)
    json.priority issue.priority.try(:name)
    json.version issue.version.try(:name)
    json.journals_count issue.get_journals_size
    json.issue_tags issue.get_issue_tags
    json.attached_issues pr.attached_issues.each do |issue|
      json.(issue, :id, :subject, :project_issues_index)
    end    
  end
end

