Sha256: 08e7a2a5a18933e887e776119a2c979a3239b7b056e573d7e55c84b87233e7d5

Contents?: true

Size: 1.61 KB

Versions: 12

Compression:

Stored size: 1.61 KB

Contents

require_dependency "hubstats/application_controller"

module Hubstats
  class PullRequestsController < ApplicationController

    def index
      URI.decode(params[:label]) if params[:label]

      pull_ids = Hubstats::PullRequest
        .belonging_to_users(params[:users])
        .belonging_to_repos(params[:repos])
        .state_based_order(@timespan,params[:state],"ASC")
        .map(&:id)

      @labels = Hubstats::Label.with_a_pull_request(pull_ids).order("pull_request_count DESC")

      @pull_requests = Hubstats::PullRequest.includes(:user).includes(:repo)
        .belonging_to_users(params[:users]).belonging_to_repos(params[:repos])
        .group_by(params[:group]).with_label(params[:label])
        .state_based_order(@timespan,params[:state],params[:order])
        .paginate(:page => params[:page], :per_page => 15)

      if params[:group] == 'user'
        @groups = @pull_requests.to_a.group_by(&:user_name)
      elsif params[:group] == 'repo'
        @groups = @pull_requests.to_a.group_by(&:repo_name)
      end

    end 

    def show
      @repo = Hubstats::Repo.where(name: params[:repo]).first
      @pull_request = Hubstats::PullRequest.belonging_to_repo(@repo.id).where(id: params[:id]).first
      @comments = Hubstats::Comment.belonging_to_pull_request(params[:id]).includes(:user).created_since(@timespan).limit(20)
      @comment_count = Hubstats::Comment.belonging_to_pull_request(params[:id]).includes(:user).created_since(@timespan).count(:all)
      @stats = {
        comment_count: @comment_count,
        net_additions: @pull_request.additions.to_i - @pull_request.deletions.to_i
      }
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hubstats-0.3.4 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.3.3 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.3.2 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.3.1 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.3.0 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.2.3 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.2.2 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.2.1 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.2.0 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.1.3 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.1.2 app/controllers/hubstats/pull_requests_controller.rb
hubstats-0.1.1 app/controllers/hubstats/pull_requests_controller.rb