Module: Hubstats::MetricsHelper
- Defined in:
- app/helpers/hubstats/metrics_helper.rb
Instance Method Summary collapse
-
#dashboard ⇒ Object
Public - Formats statistics for all repos/users/teams of Hubstats.
-
#get_avg_additions ⇒ Object
Public - Gets the average number of additions from all pull requests within the start date and end date.
-
#get_avg_deletions ⇒ Object
Public - Gets the average number of deletions from all pull requests within the start date and end date.
-
#get_comment_count ⇒ Object
Public - Gets the number of comments within the start date and end date.
-
#get_comments_per_rev ⇒ Object
Public - Gets the number of comments per reviewer within the start date and end date.
-
#get_deploy_count ⇒ Object
Public - Gets the number of deployments within the start date and end date.
-
#get_developer_count ⇒ Object
Public - Gets the number of active developers within the start date and end date.
-
#get_net_additions ⇒ Object
Public - Gets the total net additions from all pull requests within the start date and end date.
-
#get_pull_count ⇒ Object
Public - Gets the number of pull requests within the start date and end date.
-
#get_pulls_per_dev ⇒ Object
Public - Gets the number of pull requests per developer within the start date and end date.
-
#get_qa_signoff_count ⇒ Object
Public - Gets the number of QA signoffs within the start date and end date.
-
#get_reviewer_count ⇒ Object
Public - Gets the number of active reviewers within the start date and end date.
Instance Method Details
#dashboard ⇒ Object
Public - Formats statistics for all repos/users/teams of Hubstats
Returns - all of the stats in a corresponding hash
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 95 def dashboard @stats_row_one = { developer_count: get_developer_count, pull_count: get_pull_count, pulls_per_dev: get_pulls_per_dev, qa_signoff_count: get_qa_signoff_count, net_additions: get_net_additions } @stats_row_two = { reviewer_count: get_reviewer_count, comment_count: get_comment_count, comments_per_rev: get_comments_per_rev, avg_additions: get_avg_additions, avg_deletions: get_avg_deletions } end |
#get_avg_additions ⇒ Object
Public - Gets the average number of additions from all pull requests within the start date and end date
Returns - the average additions
79 80 81 82 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 79 def get_avg_additions num = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).average(:additions) || 0 return num.round.to_i end |
#get_avg_deletions ⇒ Object
Public - Gets the average number of deletions from all pull requests within the start date and end date
Returns - the average deletions
87 88 89 90 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 87 def get_avg_deletions num = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).average(:deletions) || 0 return num.round.to_i end |
#get_comment_count ⇒ Object
Public - Gets the number of comments within the start date and end date
Returns - the number of comments
35 36 37 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 35 def get_comment_count Hubstats::Comment.created_in_date_range(@start_date, @end_date).ignore_comments_by(Hubstats::User.ignore_users_ids).count(:all) end |
#get_comments_per_rev ⇒ Object
Public - Gets the number of comments per reviewer within the start date and end date
Returns - the number of comments per reviewer
49 50 51 52 53 54 55 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 49 def get_comments_per_rev if get_reviewer_count != 0 comments_per_rev = (get_comment_count.to_f / get_reviewer_count.to_f).round(2) else comments_per_rev = 0 end end |
#get_deploy_count ⇒ Object
Public - Gets the number of deployments within the start date and end date
Returns - the number of deployments
21 22 23 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 21 def get_deploy_count Hubstats::Deploy.deployed_in_date_range(@start_date, @end_date).count(:all) end |
#get_developer_count ⇒ Object
Public - Gets the number of active developers within the start date and end date
Returns - the number of developers
7 8 9 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 7 def get_developer_count Hubstats::User.count_active_developers(@start_date, @end_date) end |
#get_net_additions ⇒ Object
Public - Gets the total net additions from all pull requests within the start date and end date
Returns - the net additions
71 72 73 74 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 71 def get_net_additions Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).sum(:additions).to_i - Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).sum(:deletions).to_i end |
#get_pull_count ⇒ Object
Public - Gets the number of pull requests within the start date and end date
Returns - the number of pull requests
28 29 30 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 28 def get_pull_count Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).ignore_pulls_by(Hubstats::User.ignore_users_ids).count(:all) end |
#get_pulls_per_dev ⇒ Object
Public - Gets the number of pull requests per developer within the start date and end date
Returns - the number of pull requests per developer
60 61 62 63 64 65 66 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 60 def get_pulls_per_dev if get_developer_count != 0 pulls_per_dev = (get_pull_count.to_f / get_developer_count.to_f).round(2) else pulls_per_dev = 0 end end |
#get_qa_signoff_count ⇒ Object
Public - Gets the number of QA signoffs within the start date and end date
Returns - the number of QA signoffs
42 43 44 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 42 def get_qa_signoff_count Hubstats::QaSignoff.signed_within_date_range(@start_date, @end_date).count(:all) end |
#get_reviewer_count ⇒ Object
Public - Gets the number of active reviewers within the start date and end date
Returns - the number of reviewers
14 15 16 |
# File 'app/helpers/hubstats/metrics_helper.rb', line 14 def get_reviewer_count Hubstats::User.count_active_reviewers(@start_date, @end_date) end |