bin/pull_req_data_extraction.rb
def commit_entries(pr_id, at_open = false)
    if at_open
      q = <<-QUERY
        select c.sha as sha
        from pull_requests pr, pull_request_commits prc,
             commits c, pull_request_history prh
        where pr.id = prc.pull_request_id
        and prc.commit_id = c.id
        and prh.action = 'opened'
        and prh.pull_request_id = pr.id
        and c.created_at <= prh.created_at
        and pr.id = ?
      QUERY
    else
      q = <<-QUERY
        select c.sha as sha
        from pull_requests pr, pull_request_commits prc, commits c
        where pr.id = prc.pull_request_id
        and prc.commit_id = c.id
        and pr.id = ?
      QUERY
    end

    commits = db.fetch(q, pr_id).all

    commits.reduce([]){ |acc, x|
      a = mongo['commits'].find({:sha => x[:sha]}).limit(1).first

      if a.nil?
        a = github_commit(owner, repo, x)
      end

      acc << a unless a.nil?
      acc
    }.select{|c| c['parents'].size <= 1}
  end
# JSON objects for the commits included in the pull request
JSON objects for the commits included in the pull request
JSON objects for the commits included in the pull request
def commit_entries(pr_id, at_open = false)
    if at_open
      q = <<-QUERY
        select c.sha as sha
        from pull_requests pr, pull_request_commits prc,
             commits c, pull_request_history prh
        where pr.id = prc.pull_request_id
        and prc.commit_id = c.id
        and prh.action = 'opened'
        and prh.pull_request_id = pr.id
        and c.created_at <= prh.created_at
        and pr.id = ?
      QUERY
    else
      q = <<-QUERY
        select c.sha as sha
        from pull_requests pr, pull_request_commits prc, commits c
        where pr.id = prc.pull_request_id
        and prc.commit_id = c.id
        and pr.id = ?
      QUERY
    end
    commits = db.fetch(q, pr_id).all
    commits.reduce([]){ |acc, x|
      a = mongo['commits'].find({:sha => x[:sha]}).limit(1).first
      if a.nil?
        a = github_commit(owner, repo, x)
      end
      acc << a unless a.nil?
      acc
    }.select{|c| c['parents'].size <= 1}
  end
def commit_entries ( pr_id , at_open = false ) if at_open q = <<-QUERY 
        select c.sha as sha
        from pull_requests pr, pull_request_commits prc,
             commits c, pull_request_history prh
        where pr.id = prc.pull_request_id
        and prc.commit_id = c.id
        and prh.action = 'opened'
        and prh.pull_request_id = pr.id
        and c.created_at <= prh.created_at
        and pr.id = ?
       QUERY else q = <<-QUERY 
        select c.sha as sha
        from pull_requests pr, pull_request_commits prc, commits c
        where pr.id = prc.pull_request_id
        and prc.commit_id = c.id
        and pr.id = ?
       QUERY end commits = db . fetch ( q , pr_id ) . all commits . reduce ( [ ] ) { | acc , x | a = mongo [ 'commits' ] . find ( { :sha => x [ :sha ] } ) . limit ( 1 ) . first if a . nil? a = github_commit ( owner , repo , x ) end acc << a unless a . nil? acc } . select { | c | c [ 'parents' ] . size <= 1 } end
JSON objects for the commits included in the pull request
JSON objects for the commits included in the pull request
pr_id
at_open