bin/pull_req_data_extraction.rb
def pull_reqs(project, github_id = -1)
    q = <<-QUERY
    select u.login as login, p.name as project_name, pr.id, pr.pullreq_id as github_id,
           a.created_at as created_at, b.created_at as closed_at, c.sha as base_commit,
           c1.sha as head_commit,
			     ( select created_at
             from pull_request_history prh1
             where prh1.pull_request_id = pr.id
             and prh1.action='merged' limit 1) as merged_at,
           timestampdiff(minute, a.created_at, b.created_at) as lifetime_minutes,
			     timestampdiff(minute, a.created_at, (select created_at
                                           from pull_request_history prh1
                                           where prh1.pull_request_id = pr.id and prh1.action='merged' limit 1)) as mergetime_minutes
    from pull_requests pr, projects p, users u,
         pull_request_history a, pull_request_history b, commits c, commits c1
    where p.id = pr.base_repo_id
	    and a.pull_request_id = pr.id
      and a.pull_request_id = b.pull_request_id
      and a.action='opened' and b.action='closed'
	    and a.created_at < b.created_at
      and p.owner_id = u.id
      and c1.id = pr.head_commit_id
      and c.id = pr.base_commit_id
      and p.id = ?
    QUERY

    if github_id != -1
      q += " and pr.pullreq_id = #{github_id} "
    end
    q += 'group by pr.id order by pr.pullreq_id desc;'

    db.fetch(q, project[:id]).all
  end
# Get a list of pull requests for the processed project
Get a list of pull requests for the processed project
Get a list of pull requests for the processed project
def pull_reqs(project, github_id = -1)
    q = <<-QUERY
    select u.login as login, p.name as project_name, pr.id, pr.pullreq_id as github_id,
           a.created_at as created_at, b.created_at as closed_at, c.sha as base_commit,
           c1.sha as head_commit,
			     ( select created_at
             from pull_request_history prh1
             where prh1.pull_request_id = pr.id
             and prh1.action='merged' limit 1) as merged_at,
           timestampdiff(minute, a.created_at, b.created_at) as lifetime_minutes,
			     timestampdiff(minute, a.created_at, (select created_at
                                           from pull_request_history prh1
                                           where prh1.pull_request_id = pr.id and prh1.action='merged' limit 1)) as mergetime_minutes
    from pull_requests pr, projects p, users u,
         pull_request_history a, pull_request_history b, commits c, commits c1
    where p.id = pr.base_repo_id
	    and a.pull_request_id = pr.id
      and a.pull_request_id = b.pull_request_id
      and a.action='opened' and b.action='closed'
	    and a.created_at < b.created_at
      and p.owner_id = u.id
      and c1.id = pr.head_commit_id
      and c.id = pr.base_commit_id
      and p.id = ?
    QUERY
    if github_id != -1
      q += " and pr.pullreq_id = #{github_id} "
    end
    q += 'group by pr.id order by pr.pullreq_id desc;'
    db.fetch(q, project[:id]).all
  end
def pull_reqs ( project , github_id = - 1 ) q = <<-QUERY 
    select u.login as login, p.name as project_name, pr.id, pr.pullreq_id as github_id,
           a.created_at as created_at, b.created_at as closed_at, c.sha as base_commit,
           c1.sha as head_commit,
			     ( select created_at
             from pull_request_history prh1
             where prh1.pull_request_id = pr.id
             and prh1.action='merged' limit 1) as merged_at,
           timestampdiff(minute, a.created_at, b.created_at) as lifetime_minutes,
			     timestampdiff(minute, a.created_at, (select created_at
                                           from pull_request_history prh1
                                           where prh1.pull_request_id = pr.id and prh1.action='merged' limit 1)) as mergetime_minutes
    from pull_requests pr, projects p, users u,
         pull_request_history a, pull_request_history b, commits c, commits c1
    where p.id = pr.base_repo_id
	    and a.pull_request_id = pr.id
      and a.pull_request_id = b.pull_request_id
      and a.action='opened' and b.action='closed'
	    and a.created_at < b.created_at
      and p.owner_id = u.id
      and c1.id = pr.head_commit_id
      and c.id = pr.base_commit_id
      and p.id = ?
     QUERY if github_id != - 1 q += " and pr.pullreq_id = #{github_id} " end q += 'group by pr.id order by pr.pullreq_id desc;' db . fetch ( q , project [ :id ] ) . all end
Get a list of pull requests for the processed project
Get a list of pull requests for the processed project
project
github_id