bin/pull_req_data_extraction.rb
# Total number of commits on the project in the period up to `months` before
# the pull request was opened. `exclude_pull_req` controls whether commits
# from pull requests should be accounted for.
Total number of commits on the project in the period up to `months` before
the pull request was opened. `exclude_pull_req` controls whether commits
from pull requests should be accounted for.
Total number of commits on the project in the period up to ` months ` before the pull request was opened . ` exclude_pull_req ` controls whether commits from pull requests should be accounted for .
def commits_last_x_months(pr, exclude_pull_req, months_back)
    q = <<-QUERY
    select count(c.id) as num_commits
    from projects p, commits c, project_commits pc, pull_requests pr,
         pull_request_history prh
    where p.id = pc.project_id
      and pc.commit_id = c.id
      and p.id = pr.base_repo_id
      and prh.pull_request_id = pr.id
      and prh.action = 'opened'
      and c.created_at < prh.created_at
      and c.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)
      and pr.id=?
    QUERY
    if exclude_pull_req
      q << ' and not exists (select * from pull_request_commits prc1 where prc1.commit_id = c.id)'
    end
    db.fetch(q, pr[:id]).first[:num_commits]
  end
def commits_last_x_months ( pr , exclude_pull_req , months_back ) q = <<-QUERY 
    select count(c.id) as num_commits
    from projects p, commits c, project_commits pc, pull_requests pr,
         pull_request_history prh
    where p.id = pc.project_id
      and pc.commit_id = c.id
      and p.id = pr.base_repo_id
      and prh.pull_request_id = pr.id
      and prh.action = 'opened'
      and c.created_at < prh.created_at
      and c.created_at > DATE_SUB(prh.created_at, INTERVAL  #{ months_back }  MONTH)
      and pr.id=?
     QUERY if exclude_pull_req q << ' and not exists (select * from pull_request_commits prc1 where prc1.commit_id = c.id)' end db . fetch ( q , pr [ :id ] ) . first [ :num_commits ] end
Total number of commits on the project in the period up to `months` before
the pull request was opened.
Total number of commits on the project in the period up to ` months ` before the pull request was opened .
pr
exclude_pull_req
months_back