hubstats 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +5 -13
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.markdown +5 -0
  5. data/README.md +64 -22
  6. data/app/assets/javascripts/hubstats/pull_requests.js +5 -0
  7. data/app/assets/javascripts/hubstats/select2.js +46 -3
  8. data/app/assets/javascripts/hubstats/users.js +8 -0
  9. data/app/assets/stylesheets/hubstats/application.css +5 -1
  10. data/app/controllers/hubstats/pull_requests_controller.rb +2 -3
  11. data/app/controllers/hubstats/repos_controller.rb +7 -12
  12. data/app/controllers/hubstats/teams_controller.rb +62 -0
  13. data/app/controllers/hubstats/users_controller.rb +9 -8
  14. data/app/models/hubstats/comment.rb +1 -0
  15. data/app/models/hubstats/pull_request.rb +40 -8
  16. data/app/models/hubstats/repo.rb +1 -1
  17. data/app/models/hubstats/team.rb +159 -0
  18. data/app/models/hubstats/user.rb +10 -1
  19. data/app/views/hubstats/deploys/show.html.erb +1 -4
  20. data/app/views/hubstats/partials/_comment-condensed.html.erb +1 -0
  21. data/app/views/hubstats/partials/_comment.html.erb +1 -0
  22. data/app/views/hubstats/partials/_footer.html.erb +3 -0
  23. data/app/views/hubstats/partials/_header.html.erb +5 -3
  24. data/app/views/hubstats/partials/_team.html.erb +40 -0
  25. data/app/views/hubstats/partials/_user-condensed.html.erb +6 -5
  26. data/app/views/hubstats/partials/_user.html.erb +2 -1
  27. data/app/views/hubstats/pull_requests/index.html.erb +4 -0
  28. data/app/views/hubstats/repos/dashboard.html.erb +0 -1
  29. data/app/views/hubstats/repos/show.html.erb +1 -1
  30. data/app/views/hubstats/tables/_comments-condensed.html.erb +1 -1
  31. data/app/views/hubstats/tables/_comments.html.erb +1 -1
  32. data/app/views/hubstats/tables/_deploys.html.erb +1 -1
  33. data/app/views/hubstats/tables/_grouped_deploys.html.erb +1 -1
  34. data/app/views/hubstats/tables/_grouped_pulls.html.erb +1 -1
  35. data/app/views/hubstats/tables/_pulls-condensed.html.erb +1 -1
  36. data/app/views/hubstats/tables/_pulls.html.erb +1 -1
  37. data/app/views/hubstats/tables/_repos-condensed.html.erb +1 -1
  38. data/app/views/hubstats/tables/_repos.html.erb +2 -2
  39. data/app/views/hubstats/tables/_teams.html.erb +28 -0
  40. data/app/views/hubstats/tables/_users-condensed.html.erb +1 -1
  41. data/app/views/hubstats/tables/_users.html.erb +2 -2
  42. data/app/views/hubstats/teams/index.html.erb +10 -0
  43. data/app/views/hubstats/teams/show.html.erb +28 -0
  44. data/app/views/hubstats/users/show.html.erb +2 -2
  45. data/config/routes.rb +4 -3
  46. data/db/migrate/20150706204910_create_hubstats_teams.rb +8 -0
  47. data/db/migrate/20150706205049_create_hubstats_teams_users.rb +8 -0
  48. data/db/migrate/20150713185013_add_team_id_to_prs.rb +5 -0
  49. data/hubstats.gemspec +2 -1
  50. data/lib/generators/hubstats/octokit.example.yml +3 -1
  51. data/lib/hubstats/events_handler.rb +20 -0
  52. data/lib/hubstats/github_api.rb +71 -15
  53. data/lib/hubstats/version.rb +1 -1
  54. data/lib/tasks/hubstats_tasks.rake +19 -0
  55. data/lib/tasks/populate_task.rake +35 -2
  56. data/spec/controllers/hubstats/repos_controller_spec.rb +1 -0
  57. data/spec/controllers/hubstats/teams_controller_spec.rb +39 -0
  58. data/spec/controllers/hubstats/users_controller_spec.rb +2 -0
  59. data/spec/factories/pull_requests.rb +1 -1
  60. data/spec/factories/teams.rb +24 -0
  61. data/spec/factories/users.rb +0 -1
  62. data/spec/lib/hubstats/events_handler_spec.rb +37 -7
  63. data/spec/lib/hubstats/github_api_spec.rb +55 -2
  64. data/spec/lib/hubstats_spec.rb +7 -1
  65. data/spec/models/hubstats/pull_request_spec.rb +34 -0
  66. data/spec/models/hubstats/team_spec.rb +23 -0
  67. data/spec/models/hubstats/user_spec.rb +26 -0
  68. data/test/dummy/config/initializers/octokit_patch.rb +3 -0
  69. data/test/dummy/db/schema.rb +51 -40
  70. metadata +62 -29
@@ -5,6 +5,7 @@ module Hubstats
5
5
  scope :created_in_date_range, lambda {|start_date, end_date| where("hubstats_comments.created_at BETWEEN ? AND ?", start_date, end_date)}
6
6
  scope :belonging_to_pull_request, lambda {|pull_request_id| where(pull_request_id: pull_request_id)}
7
7
  scope :belonging_to_user, lambda {|user_id| where(user_id: user_id)}
8
+ scope :belonging_to_team, lambda {|user_id| where(user_id: user_id.split(',')) if user_id}
8
9
  scope :belonging_to_repo, lambda {|repo_id| where(repo_id: repo_id)}
9
10
 
10
11
  # Public - Gets the number of PRs that a user commented on that were not their own PR.
@@ -6,10 +6,13 @@ module Hubstats
6
6
  scope :updated_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.updated_at BETWEEN ? AND ?", start_date, end_date)}
7
7
  scope :created_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.created_at BETWEEN ? AND ?", start_date, end_date)}
8
8
  scope :merged_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.merged").where("hubstats_pull_requests.merged_at BETWEEN ? AND ?", start_date, end_date)}
9
+ scope :created_since, lambda {|days| where("hubstats_pull_requests.created_at > ?", Date.today - days)}
9
10
  scope :belonging_to_repo, lambda {|repo_id| where(repo_id: repo_id)}
11
+ scope :belonging_to_team, lambda {|team_id| where(team_id: team_id)}
10
12
  scope :belonging_to_user, lambda {|user_id| where(user_id: user_id)}
11
13
  scope :belonging_to_deploy, lambda {|deploy_id| where(deploy_id: deploy_id)}
12
14
  scope :belonging_to_repos, lambda {|repo_id| where(repo_id: repo_id.split(',')) if repo_id}
15
+ scope :belonging_to_teams, lambda {|team_id| where(team_id: team_id.split(',')) if team_id}
13
16
  scope :belonging_to_users, lambda {|user_id| where(user_id: user_id.split(',')) if user_id}
14
17
  scope :group, lambda {|group| group_by(:repo_id) if group }
15
18
  scope :with_state, lambda {|state| (where(state: state) unless state == 'all') if state}
@@ -22,15 +25,18 @@ module Hubstats
22
25
  :review_comments_url, :review_comment_url, :comments_url, :statuses_url, :number,
23
26
  :state, :title, :body, :created_at, :updated_at, :closed_at, :merged_at,
24
27
  :merge_commit_sha, :merged, :mergeable, :comments, :commits, :additions,
25
- :deletions, :changed_files, :user_id, :repo_id, :merged_by
28
+ :deletions, :changed_files, :user_id, :repo_id, :merged_by, :team_id
26
29
 
27
30
  belongs_to :user
28
31
  belongs_to :repo
29
32
  belongs_to :deploy
33
+ belongs_to :team
30
34
  has_and_belongs_to_many :labels, :join_table => "hubstats_labels_pull_requests"
31
35
 
32
36
  # Public - Makes a new pull request from a GitHub webhook. Finds user_id and repo_id based on users and repos
33
- # that are already in the Hubstats database. Also updates the user_id of a deploy if the pull request has been merged in a deploy.
37
+ # that are already in the Hubstats database. Updates the user_id of a deploy if the pull request has been merged in a deploy.
38
+ # If the user who makes the PR has a team, then it will update the team_id of the PR to match the team the user
39
+ # belongs to.
34
40
  #
35
41
  # github_pull - the info that is from Github about the new or updated pull request
36
42
  #
@@ -58,18 +64,22 @@ module Hubstats
58
64
  end
59
65
  end
60
66
 
67
+ if user.team && user.team.id
68
+ pull_data[:team_id] = user.team.id
69
+ end
70
+
61
71
  return pull if pull.update_attributes(pull_data)
62
72
  Rails.logger.warn pull.errors.inspect
63
73
  end
64
74
 
65
- # Public - Adds any labels to the labels database if the labels passed in aren't already there.
75
+ # Public - Takes days, a number, and updates all pull requests' team_ids that were created since that many days ago
66
76
  #
67
- # labels - the labels to be added to the db
77
+ # days - the amount of days ago that we wish to grab the number of pull requests since
68
78
  #
69
- # Returns - the new labels
70
- def add_labels(labels)
71
- labels.map!{|label| Hubstats::Label.first_or_create(label) }
72
- self.labels = labels
79
+ # Returns - nothing
80
+ def self.update_teams_in_pulls(days)
81
+ pulls = created_since(days)
82
+ pulls.each {|pull| pull.assign_team_from_user}
73
83
  end
74
84
 
75
85
  # Public - Filters all of the pull requests between start_date and end_date that are the given state
@@ -84,6 +94,7 @@ module Hubstats
84
94
  filter_based_on_date_range(start_date, end_date, params[:state])
85
95
  .belonging_to_users(params[:users])
86
96
  .belonging_to_repos(params[:repos])
97
+ .belonging_to_teams(params[:teams])
87
98
  end
88
99
 
89
100
  # Public - Finds all of the PRs with the current state, and then filters to ones that have been updated in
@@ -130,5 +141,26 @@ module Hubstats
130
141
  scoped
131
142
  end
132
143
  end
144
+
145
+ # Public - Assigns a team to a pull request based on the user's team
146
+ #
147
+ # Returns - nothing
148
+ def assign_team_from_user
149
+ user = Hubstats::User.find(self.user_id)
150
+ if user.team && user.team.id
151
+ self.team_id = user.team.id
152
+ self.save!
153
+ end
154
+ end
155
+
156
+ # Public - Adds any labels to the labels database if the labels passed in aren't already there.
157
+ #
158
+ # labels - the labels to be added to the db
159
+ #
160
+ # Returns - the new labels
161
+ def add_labels(labels)
162
+ labels.map!{|label| Hubstats::Label.first_or_create(label) }
163
+ self.labels = labels
164
+ end
133
165
  end
134
166
  end
@@ -134,7 +134,7 @@ module Hubstats
134
134
  order("pull_request_count DESC")
135
135
  end
136
136
  end
137
-
137
+
138
138
  # Public - Designed to make a path for the show page when a repository is selected.
139
139
  #
140
140
  # Returns - the show page of self.name
@@ -0,0 +1,159 @@
1
+ module Hubstats
2
+ class Team < ActiveRecord::Base
3
+
4
+ scope :with_id, lambda {|team_id| where(id: team_id.split(',')) if team_id}
5
+
6
+ # Public - Counts all of the users that are a part of the selected team.
7
+ #
8
+ # start_date - the start of the date range
9
+ # end_date - the end of the date range
10
+ #
11
+ # Returns - the count of users
12
+ scope :users_count, lambda {|start_date, end_date|
13
+ select("hubstats_teams.id as team_id")
14
+ .select("COUNT(DISTINCT hubstats_teams_users.user_id) AS user_count")
15
+ .where("hubstats_users.login NOT IN (?)", Hubstats.config.github_config["ignore_users_list"])
16
+ .joins(:users)
17
+ .group("hubstats_teams.id")
18
+ }
19
+
20
+ # Public - Counts all of the comments a selected team's members have written that occurred between the start_date and end_date.
21
+ #
22
+ # start_date - the start of the date range
23
+ # end_date - the end of the data range
24
+ # user_id_array - an array of all of the user ids in selected team
25
+ #
26
+ # Returns - count of comments
27
+ scope :comments_count, lambda {|start_date, end_date|
28
+ select("IFNULL(COUNT(DISTINCT hubstats_comments.id),0) AS comment_count, hubstats_teams.id as team_id")
29
+ .joins("LEFT OUTER JOIN hubstats_teams_users ON hubstats_teams.id = hubstats_teams_users.team_id")
30
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_comments ON (hubstats_comments.user_id = hubstats_teams_users.user_id) AND (hubstats_comments.created_at BETWEEN ? AND ?)", start_date, end_date]))
31
+ .group("hubstats_teams.id")
32
+ }
33
+
34
+ # Public - Counts all of the repos a selected team's members have made PRs or comments on.
35
+ #
36
+ # start_date - the start of the date range
37
+ # end_date - the end of the data range
38
+ #
39
+ # Returns - count of repos
40
+ scope :repos_count, lambda {|start_date, end_date|
41
+ select("hubstats_teams.id as team_id")
42
+ .select("IFNULL(COUNT(DISTINCT hubstats_pull_requests.repo_id),0) AS repo_count")
43
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.team_id = hubstats_teams.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND hubstats_pull_requests.merged = '1'", start_date, end_date]))
44
+ .group("hubstats_teams.id")
45
+ }
46
+
47
+ # Public - Counts all of the merged pull requests for selected team's users that occurred between the start_date and end_date.
48
+ #
49
+ # start_date - the start of the date range
50
+ # end_date - the end of the data range
51
+ #
52
+ # Returns - count of pull requests
53
+ scope :pull_requests_count, lambda {|start_date, end_date|
54
+ select("hubstats_teams.id as team_id")
55
+ .select("IFNULL(COUNT(DISTINCT hubstats_pull_requests.id),0) AS pull_request_count")
56
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.team_id = hubstats_teams.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND hubstats_pull_requests.merged = '1'", start_date, end_date]))
57
+ .group("hubstats_teams.id")
58
+ }
59
+
60
+ # Public - Counts all of the addtiions and deletions made from PRs by a member of the selected team that have been merged between the start_date
61
+ # and the end_date.
62
+ #
63
+ # start_date - the start of the date range
64
+ # end_date - the end of the data range
65
+ #
66
+ # Returns - the additions and deletions
67
+ scope :net_additions_count, lambda {|start_date, end_date|
68
+ select("hubstats_teams.id as team_id")
69
+ .select("SUM(IFNULL(hubstats_pull_requests.additions, 0)) AS additions")
70
+ .select("SUM(IFNULL(hubstats_pull_requests.deletions, 0)) AS deletions")
71
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.team_id = hubstats_teams.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND hubstats_pull_requests.merged = '1'", start_date, end_date]))
72
+ .group("hubstats_teams.id")
73
+ }
74
+
75
+ # Public - Joins all of the metrics together for selected team: net additions, comments, repos, pull requests, and users.
76
+ #
77
+ # start_date - the start of the date range
78
+ # end_date - the end of the data range
79
+ #
80
+ # Returns - all of the stats about the team
81
+ scope :with_all_metrics, lambda {|start_date, end_date|
82
+ select("hubstats_teams.*, user_count, pull_request_count, comment_count, repo_count,additions, deletions")
83
+ .joins("LEFT JOIN (#{net_additions_count(start_date, end_date).to_sql}) AS net_additions ON net_additions.team_id = hubstats_teams.id")
84
+ .joins("LEFT JOIN (#{pull_requests_count(start_date, end_date).to_sql}) AS pull_requests ON pull_requests.team_id = hubstats_teams.id")
85
+ .joins("LEFT JOIN (#{comments_count(start_date, end_date).to_sql}) AS comments ON comments.team_id = hubstats_teams.id")
86
+ .joins("LEFT JOIN (#{repos_count(start_date, end_date).to_sql}) AS repos ON repos.team_id = hubstats_teams.id")
87
+ .joins("LEFT JOIN (#{users_count(start_date, end_date).to_sql}) AS users ON users.team_id = hubstats_teams.id")
88
+ .group("hubstats_teams.id")
89
+ }
90
+
91
+ attr_accessible :name, :hubstats
92
+ has_and_belongs_to_many :users, :join_table => 'hubstats_teams_users', :uniq => true
93
+
94
+ # Public - Checks if the team is currently existing, and if it isn't, then makes a new team with
95
+ # the specifications that are passed in. We are assuming that if it is not already existent,
96
+ # then we probably don't really care about the team, so our hubstats boolean will be set to false.
97
+ #
98
+ # github_team - the info that's passed in about the new or updated team
99
+ #
100
+ # Returns - the team
101
+ def self.create_or_update(github_team)
102
+ github_team = github_team.to_h.with_indifferent_access if github_team.respond_to? :to_h
103
+
104
+ team_data = github_team.slice(*Hubstats::Team.column_names.map(&:to_sym))
105
+ team = where(:id => team_data[:id]).first_or_create(team_data)
106
+
107
+ team_data[:hubstats] = true
108
+
109
+ return team if team.update_attributes(team_data)
110
+ Rails.logger.warn team.errors.inspect
111
+ end
112
+
113
+ # Public - Adds or removes a user from a team
114
+ #
115
+ # team - a hubstats team that we wish to edit the users of
116
+ # user - a hubstats user that we wish to remove or add to the team
117
+ # action - whether the user is to be removed or added (string)
118
+ #
119
+ # Returns - nothing
120
+ def self.update_users_in_team(team, user, action)
121
+ if action == "added"
122
+ team.users << user
123
+ elsif action == "removed"
124
+ team.users.delete(user)
125
+ end
126
+ team.save!
127
+ end
128
+
129
+ # Public - Designed so that the list of teams can be ordered based on users, pulls, comments, net additions, or name.
130
+ # if none of these are selected, then the default is to order by pull request count in descending order.
131
+ #
132
+ # order_params - the param of what the teams should be sorted by
133
+ #
134
+ # Returns - the team data ordered
135
+ def self.custom_order(order_params)
136
+ if order_params
137
+ order = order_params.include?('asc') ? "ASC" : "DESC"
138
+ case order_params.split('-').first
139
+ when 'usercount'
140
+ order("user_count #{order}")
141
+ when 'pulls'
142
+ order("pull_request_count #{order}")
143
+ when 'comments'
144
+ order("comment_count #{order}")
145
+ when 'netadditions'
146
+ order("additions - deletions #{order}")
147
+ when 'repocount'
148
+ order("repo_count #{order}")
149
+ when 'name'
150
+ order("name #{order}")
151
+ else
152
+ order("pull_request_count #{order}")
153
+ end
154
+ else
155
+ order("pull_request_count DESC")
156
+ end
157
+ end
158
+ end
159
+ end
@@ -144,7 +144,7 @@ module Hubstats
144
144
  .group("hubstats_users.id")
145
145
  }
146
146
 
147
- # Public - Joins all of the metrics together for selected repository: average additions and deletions, comments, pull requests, and deploys.
147
+ # Public - Joins all of the metrics together for selected user: average additions and deletions, comments, pull requests, and deploys.
148
148
  #
149
149
  # start_date - the start of the date range
150
150
  # end_date - the end of the data range
@@ -169,6 +169,7 @@ module Hubstats
169
169
  has_many :repos, :class_name => "Repo"
170
170
  has_many :pull_requests
171
171
  has_many :deploys
172
+ has_and_belongs_to_many :teams, :join_table => 'hubstats_teams_users', :uniq => true
172
173
 
173
174
  # Public - Creates a new user form a GitHub webhook.
174
175
  #
@@ -231,6 +232,14 @@ module Hubstats
231
232
  end
232
233
  end
233
234
 
235
+ # Public - Gets the first team where the user is belongs to and where hubstats bool is true.
236
+ #
237
+ # Returns - the first team that the user belongs to where hubstats bool is true, if nothing
238
+ # meets these qualifications, nil is returned
239
+ def team
240
+ teams.where(hubstats: true).first
241
+ end
242
+
234
243
  # Public - Designed to make a path for the show page when a repository is selected.
235
244
  #
236
245
  # Returns - the show page of self.name
@@ -7,8 +7,6 @@
7
7
  <%= @deploy.git_revision.titleize %>
8
8
  </h1>
9
9
 
10
- <br>
11
-
12
10
  <!-- Show the date/time that the deploy was deployed -->
13
11
  <h4 class="text-center">
14
12
  Deployed at: <%= @deploy.deployed_at %>
@@ -21,12 +19,11 @@
21
19
  <!--Show all of the pull requests in a "condensed" view -->
22
20
  <div class="col col-lg-8 col-lg-offset-2">
23
21
  <div class="row">
24
- <h4> Pull Requests </h4>
22
+ <h4> Merged Pull Requests </h4>
25
23
  <%= render 'hubstats/tables/pulls-condensed' %>
26
24
  <% if @pull_request_count > 20 %>
27
25
  <p class="pull-right"><%= link_to "View All", pulls_path(:deploys => @deploy.id) %></p>
28
26
  <% end %>
29
27
  </div>
30
28
  </div>
31
-
32
29
  </div>
@@ -14,6 +14,7 @@
14
14
  </div>
15
15
  </div>
16
16
 
17
+ <!-- Show the github octcat sign with a link to the comment on github -->
17
18
  <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
18
19
  <div class="pull-right">
19
20
  <a class="subtle" href=<%= comment.html_url %> >
@@ -14,6 +14,7 @@
14
14
  </div>
15
15
  </div>
16
16
 
17
+ <!-- Show the github octcat sign with a link to the comment on github -->
17
18
  <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
18
19
  <div class="pull-right">
19
20
  <a class="subtle" href=<%= comment.html_url %> >
@@ -2,11 +2,13 @@
2
2
  <hr>
3
3
  <div class="row">
4
4
  <div class="col-lg-3 col-md-3 col-sm-3">
5
+ <!-- Show the Sport Ngin copyright information, change if using a different copyright -->
5
6
  <div class="footer-text">
6
7
  © 2015 Sport Ngin
7
8
  </div>
8
9
  </div>
9
10
  <div class="col-lg-6 col-md-6 col-sm-6">
11
+ <!-- Show the Hubstats name in the footer -->
10
12
  <div class="footer-main-text">
11
13
  Hubstats
12
14
  <br>
@@ -14,6 +16,7 @@
14
16
  </div>
15
17
  </div>
16
18
  <div class="col-lg-3 col-md-3 col-sm-3">
19
+ <!-- Have a link to the Hubstats source code on github, change if wishing to connect to a different repository -->
17
20
  <div class="footer-text" align="right">
18
21
  <%= link_to("Source Code", "https://github.com/sportngin/hubstats") %>
19
22
  </div>
@@ -2,7 +2,7 @@
2
2
  <nav class="navbar navbar-default" role="navigation">
3
3
  <div class="container-fluid">
4
4
 
5
- <!-- Show the Hubstats name in navbar along with a link to the PR page -->
5
+ <!-- Show the Hubstats name in navbar along with a link to the PR page that shows current open and deployable PRs sorted by repo -->
6
6
  <div class="navbar-header">
7
7
  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
8
8
  <span class="sr-only">Toggle navigation</span>
@@ -11,12 +11,14 @@
11
11
  <span class="icon-bar"></span>
12
12
  </button>
13
13
  <%= link_to "Hubstats", root_path(:state => "open", :label => "deployable", :group => "repo"),
14
- {:data => {:repo_path => repos_path(), :user_path => users_path()}, :class => "navbar-brand title", :id =>"brand"}%>
14
+ {:data => {:repo_path => repos_path(), :user_path => users_path(), :team_path => teams_path()}, :class => "navbar-brand title", :id =>"brand"}%>
15
15
  </div>
16
16
 
17
- <!-- Show all of the pages in tab form -->
17
+ <!-- Show all of the pages (Teams, Deployments, Metrics, Pull Requests, Users) in tab form -->
18
18
  <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
19
19
  <ul class="nav navbar-nav navbar-right">
20
+ <li class="<%='navbar-active' if params[:controller] == 'hubstats/teams'%>">
21
+ <%= link_to "Teams", teams_path%></li>
20
22
  <li class="<%='navbar-active' if params[:controller] == 'hubstats/deploys'%>">
21
23
  <%= link_to "Deployments", deploys_path%></li>
22
24
  <li class="<%='navbar-active' if params[:controller] == 'hubstats/repos'%>">
@@ -0,0 +1,40 @@
1
+ <div class="row single-team">
2
+
3
+ <!-- Show the team name and the date that it was last updated, with a link to the github team -->
4
+ <div class="team-info col-lg-2 col-md-2 col-sm-2 col-xs-8">
5
+ <h4>
6
+ <%= link_to team.name, team_path(team)%>
7
+ </h4>
8
+ <br>
9
+ </div>
10
+
11
+ <!-- Show all of the stats for the individual team -->
12
+ <div class="col-lg-2 col-md-2 col-sm-2">
13
+ <div class="text-center">
14
+ <span class="text-large"><%= team.user_count || 0 %></span> <!-- minus one for the user we're using as the access_token -->
15
+ </div>
16
+ </div>
17
+ <div class="col-lg-2 col-md-2 col-sm-2">
18
+ <div class="text-center">
19
+ <span class="text-large"><%= team.pull_request_count %></span>
20
+ <span class="mega-octicon octicon-git-pull-request"></span>
21
+ </div>
22
+ </div>
23
+ <div class="col-lg-2 col-md-2 col-sm-2">
24
+ <div class="text-center">
25
+ <span class="text-large"><%= team.comment_count %></span>
26
+ <span class="mega-octicon octicon-comment"></span>
27
+ </div>
28
+ </div>
29
+ <div class="col-lg-2 col-md-2 col-sm-2">
30
+ <div class="text-center">
31
+ <span class="text-large"><%= team.repo_count %></span>
32
+ <span class="mega-octicon octicon-repo"></span>
33
+ </div>
34
+ </div>
35
+ <div class="col-lg-2 col-md-2 col-sm-2">
36
+ <div class="text-center">
37
+ <span class="text-large"><%= team.additions - team.deletions %></span>
38
+ </div>
39
+ </div>
40
+ </div>
@@ -4,23 +4,24 @@
4
4
  <div class="user-image-small col-lg-1 col-md-1 col-sm-1 col-xs-2" >
5
5
  <img src= <%= user.avatar_url%> alt= <%= user.login %> >
6
6
  </div>
7
- <div class="user-info col-lg-3 col-md-3 col-sm-3 col-xs-3">
7
+ <div class="user-info col-lg-4 col-md-4 col-sm-4 col-xs-4">
8
8
  <h4>
9
9
  <%= link_to user.login, user_path(user) %>
10
10
  </h4>
11
+ updated <%= distance_of_time_in_words(DateTime.now,user.updated_at) %> ago
11
12
  </div>
12
13
 
13
14
  <!-- Show the number of pull requests and comments -->
14
- <div class="col-lg-3 col-lg-offset-1 col-md-3 col-sm-3 col-xs-3">
15
+ <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
15
16
  <div class="pull-right">
16
- <span class="text-large"><%= user.pull_request_count %></span>
17
+ <span class="text-large"><%= Hubstats::PullRequest.belonging_to_user(user.id).merged_in_date_range(@start_date, @end_date).count(:all) %></span>
17
18
  <span class="mega-octicon octicon-git-pull-request"></span>
18
19
  </div>
19
20
  </div>
20
21
  <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
21
22
  <div class="pull-right">
22
- <span class="text-large"><%= user.comment_count %></span>
23
- <span class="mega-octicon octicon-comment"></span>
23
+ <span class="text-large"><%= Hubstats::Deploy.belonging_to_user(user.id).deployed_in_date_range(@start_date, @end_date).count(:all) %></span>
24
+ <span class="mega-octicon octicon-rocket"></span>
24
25
  </div>
25
26
  </div>
26
27
  <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">