class Api::V1::Projects::Pulls::PullsController < Api::V1::BaseController
  before_action :require_public_and_member_above

  def index  
    @pulls = Api::V1::Projects::Pulls::ListService.call(@project, query_params)
    @pulls = kaminari_paginate(@pulls)
  end

  before_action :load_pull_request, only: [:show] 

  def show 
   @result_object = Api::V1::Projects::Pulls::GetService.call(@project, @pull_request, current_user&.gitea_token)
   @last_review = @pull_request.reviews.order(created_at: :desc).take
  end

  private 
  def query_params 
    params.permit(:status, :keyword, :priority_id, :issue_tag_id, :version_id, :reviewer_id, :sort_by, :sort_direction)
  end
end