Class: Hubstats::TeamsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Hubstats::TeamsController
- Defined in:
- app/controllers/hubstats/teams_controller.rb
Instance Method Summary collapse
-
#index ⇒ Object
Public - Shows all of the teams in either alphabetical order, by filter params, or that have done things in github between the selected @start_date and @end_date.
-
#show ⇒ Object
Public - Will show the specific team along with the basic stats about that team, including all users and merged PRs a team member has done within the @start_date and @end_date.
-
#stats ⇒ Object
Public - Shows the basic stats for the teams show page.
Instance Method Details
#index ⇒ Object
Public - Shows all of the teams in either alphabetical order, by filter params, or that have done things in github between the selected @start_date and @end_date.
Returns - the team data
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/hubstats/teams_controller.rb', line 10 def index if params[:query] ## For select 2 @teams = Hubstats::Team.where(hubstats: true).where("name LIKE ?", "%#{params[:query]}%").order("name ASC") elsif params[:id] @teams = Hubstats::Team.where(id: params[:id].split(",")).order("name ASC") else @teams = Hubstats::Team.where(hubstats: true).with_all_metrics(@start_date, @end_date) .with_id(params[:teams]) .order_by_name .paginate(:page => params[:page], :per_page => 15) end respond_to do |format| format.html # index.html.erb format.json { render :json => @teams} end end |
#show ⇒ Object
Public - Will show the specific team along with the basic stats about that team, including all users and merged PRs a team member has done within the @start_date and @end_date.
Returns - the data of the specific team
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/hubstats/teams_controller.rb', line 32 def show @team = Hubstats::Team.where(id: params[:id]).first @pull_requests = Hubstats::PullRequest.belonging_to_team(@team.id).merged_in_date_range(@start_date, @end_date).order("updated_at DESC").limit(50) @pull_count = Hubstats::PullRequest.belonging_to_team(@team.id).merged_in_date_range(@start_date, @end_date).count(:all) @users = @team.users.where.not(login: Hubstats.config.github_config["ignore_users_list"] || []).order("login ASC").distinct @active_user_count = @users.length @comment_count = Hubstats::Comment.belonging_to_team(@users.pluck(:id)).created_in_date_range(@start_date, @end_date).count(:all) repos_pr = @pull_requests.pluck(:repo_id) repos_comment = Hubstats::Comment.belonging_to_team(@users.pluck(:id)).created_in_date_range(@start_date, @end_date).pluck(:repo_id) @repo_count = repos_pr.concat(repos_comment).uniq.count @net_additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_team(@team.id).sum(:additions).to_i - Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_team(@team.id).sum(:deletions).to_i @additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_team(@team.id).average(:additions) @deletions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_team(@team.id).average(:deletions) stats end |
#stats ⇒ Object
Public - Shows the basic stats for the teams show page.
Returns - the data in two hashes
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/hubstats/teams_controller.rb', line 53 def stats @additions ||= 0 @deletions ||= 0 @stats_row_one = { pull_count: @pull_count, active_user_count: @active_user_count, comment_count: @comment_count, repo_count: @repo_count } @stats_row_two = { avg_additions: @additions.round.to_i, avg_deletions: @deletions.round.to_i, net_additions: @net_additions } end |