hubstats 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.markdown +9 -0
  3. data/app/assets/javascripts/hubstats/bootstrap.js +38 -38
  4. data/app/assets/javascripts/hubstats/users.js +10 -5
  5. data/app/controllers/hubstats/application_controller.rb +0 -1
  6. data/app/controllers/hubstats/base_controller.rb +13 -0
  7. data/app/controllers/hubstats/deploys_controller.rb +26 -49
  8. data/app/controllers/hubstats/pull_requests_controller.rb +10 -14
  9. data/app/controllers/hubstats/repos_controller.rb +46 -24
  10. data/app/controllers/hubstats/users_controller.rb +24 -12
  11. data/app/models/hubstats/deploy.rb +36 -0
  12. data/app/models/hubstats/pull_request.rb +2 -2
  13. data/app/models/hubstats/repo.rb +63 -1
  14. data/app/models/hubstats/user.rb +29 -26
  15. data/app/views/hubstats/partials/_deploy-condensed.html.erb +1 -0
  16. data/app/views/hubstats/partials/_deploy.html.erb +1 -1
  17. data/app/views/hubstats/partials/_pull-condensed.html.erb +2 -1
  18. data/app/views/hubstats/partials/_pull.html.erb +1 -1
  19. data/app/views/hubstats/partials/_quick_addition_stats.html.erb +14 -2
  20. data/app/views/hubstats/partials/_quick_stats.html.erb +24 -12
  21. data/app/views/hubstats/partials/_repo.html.erb +37 -8
  22. data/app/views/hubstats/partials/_user.html.erb +1 -14
  23. data/app/views/hubstats/repos/dashboard.html.erb +1 -1
  24. data/app/views/hubstats/repos/show.html.erb +2 -9
  25. data/app/views/hubstats/tables/_repos.html.erb +19 -0
  26. data/app/views/hubstats/tables/_users.html.erb +1 -7
  27. data/app/views/hubstats/users/show.html.erb +3 -5
  28. data/config/routes.rb +8 -8
  29. data/lib/hubstats/github_api.rb +8 -6
  30. data/lib/hubstats/version.rb +1 -1
  31. data/spec/controllers/hubstats/deploys_controller_spec.rb +43 -47
  32. data/spec/controllers/hubstats/pull_requests_controller_spec.rb +41 -2
  33. data/spec/controllers/hubstats/repos_controller_spec.rb +62 -2
  34. data/spec/controllers/hubstats/users_controller_spec.rb +30 -2
  35. metadata +3 -2
@@ -36,20 +36,7 @@
36
36
  <!-- Show the net additions using the average_additions and the average_deletions -->
37
37
  <div class="col-lg-2 col-md-2 col-sm-2">
38
38
  <div class="text-center">
39
- <span class="text-large"><%= user.average_additions - user.average_deletions %></span>
39
+ <span class="text-large"><%= user.additions - user.deletions %></span>
40
40
  </div>
41
41
  </div>
42
- <!-- <div class="col-lg-2 col-md-2 col-sm-2">
43
- <div class="text-center">
44
- <span class="text-medium"><%= user.average_additions %></span>
45
- <span class="octicon octicon-plus"></span>
46
- </div>
47
- </div>
48
- <div class="col-lg-2 col-md-2 col-sm-2">
49
- <div class="text-center">
50
- <span class="text-medium"><%= user.average_deletions %></span>
51
- <span class="octicon octicon-dash"></span>
52
- </div>
53
- </div> -->
54
-
55
42
  </div>
@@ -6,6 +6,7 @@
6
6
  <br>
7
7
  <br>
8
8
  <br>
9
+ <br>
9
10
  <%= render 'hubstats/partials/quick_addition_stats' %>
10
11
  </div>
11
12
 
@@ -14,6 +15,5 @@
14
15
  <h3> All Repositories </h3>
15
16
  <%= render 'hubstats/tables/repos' %>
16
17
  </div>
17
-
18
18
  </div>
19
19
  </div>
@@ -1,5 +1,4 @@
1
1
  <div class="container" id="repo">
2
-
3
2
  <div class="row">
4
3
  <h1 class="title text-center"><a href=<%=@repo.html_url%>> <%= @repo.name.titleize %> </a></h1>
5
4
  <%= render 'hubstats/partials/quick_stats' %>
@@ -8,13 +7,14 @@
8
7
  <br>
9
8
  <br>
10
9
  <br>
10
+ <br>
11
11
  <%= render 'hubstats/partials/quick_addition_stats' %>
12
12
  </div>
13
13
 
14
14
  <div class="row">
15
15
 
16
16
  <div class="col col-lg-6">
17
- <h3> Pull Requests</h3>
17
+ <h3> Pull Requests</h3>
18
18
  <%= render 'hubstats/tables/pulls-condensed'%>
19
19
  <% if @pull_count > 20 %>
20
20
  <p class="pull-right"><%= link_to "View All", pulls_path(:repos => @repo.id) %></p>
@@ -29,12 +29,5 @@
29
29
  <p class="pull-right"><%= link_to "View All", deploys_path(:repos => @repo.id) %></p>
30
30
  <% end %>
31
31
  </div>
32
-
33
- <!-- <div class="col col-lg-6"> -->
34
- <!-- <h3> Active Users </h3> -->
35
- <!-- <%= render 'hubstats/tables/users-condensed' %> -->
36
- <!-- </div> -->
37
-
38
32
  </div>
39
-
40
33
  </div>
@@ -1,5 +1,24 @@
1
1
  <% if @repos.length > 0 %>
2
2
  <div class="repos">
3
+ <div class="row single-repo header">
4
+ <div class="col-lg-2 col-md-2 col-sm-2">
5
+ </div>
6
+ <div class="col-lg-2 col-md-2 col-sm-2">
7
+ <a class="header desc" id="deploys"> Deploys <span class="octicon"></span> </a>
8
+ </div>
9
+ <div class="col-lg-2 col-md-2 col-sm-2">
10
+ <a class="header desc" id="pulls"> Pulls <span class="octicon"></span> </a>
11
+ </div>
12
+ <div class="col-lg-2 col-md-2 col-sm-2">
13
+ <a class="header desc" id="comments"> Comments <span class="octicon"></span></a>
14
+ </div>
15
+ <div class="col-lg-2 col-md-2 col-sm-2">
16
+ <a class="header desc" id="additions"> Average Additions <span class="octicon"></span></a>
17
+ </div>
18
+ <div class="col-lg-2 col-md-2 col-sm-2">
19
+ <a class="header desc" id="deletions"> Average Deletions <span class="octicon"></span></a>
20
+ </div>
21
+ </div>
3
22
  <%= render partial: 'hubstats/partials/repo', collection: @repos, as: :repo %>
4
23
  </div>
5
24
  <% else %>
@@ -14,14 +14,8 @@
14
14
  </div>
15
15
  <!-- Show the net additions instead of the additions and deletions separately -->
16
16
  <div class="col-lg-2 col-md-2 col-sm-2">
17
- <a class="header desc" id="additions"> Net Average Additions <span class="octicon"></span></a>
17
+ <a class="header desc" id="netadditions"> Net Additions <span class="octicon"></span></a>
18
18
  </div>
19
- <!-- <div class="col-lg-2 col-md-2 col-sm-2">
20
- <a class="header desc" id="additions"> Additions <span class="octicon"></span></a>
21
- </div>
22
- <div class="col-lg-2 col-md-2 col-sm-2">
23
- <a class="header desc" id="deletions"> Deletions <span class="octicon"></span></a>
24
- </div> -->
25
19
  </div>
26
20
  <%= render partial: 'hubstats/partials/user', collection: @users, as: :user %>
27
21
  </div>
@@ -13,15 +13,13 @@
13
13
  <% end %>
14
14
  </div>
15
15
 
16
- <!-- <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> -->
17
- <!-- <h3> Comments </h3> -->
18
- <!-- <%= render 'hubstats/tables/comments-condensed' %> -->
19
- <!-- </div> -->
20
-
21
16
  <!-- Show all of the deploys this user did -->
22
17
  <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
23
18
  <h3> Deploys </h3>
24
19
  <%= render 'hubstats/tables/deploys-condensed' %>
20
+ <% if @deploy_count > 20 %>
21
+ <p class="pull-right"><%= link_to "View All", deploys_path(:users => @user.id) %></p>
22
+ <% end %>
25
23
  </div>
26
24
  </div>
27
25
  </div>
@@ -1,13 +1,13 @@
1
1
  Hubstats::Engine.routes.draw do
2
- root to: "pull_requests#index" #sets default root to be the pulls page
2
+ root to: "pull_requests#index" # sets default root to be the pulls page
3
3
  post "/handler" => "events#handler", :as => :handler
4
- resources :deploys, :only => [:create, :index, :show] #routes to index, show, and to create method
5
- get "/metrics" => "repos#dashboard", :as => :metrics #routes to list of repos and stats
6
- get "/pulls" => "pull_requests#index", :as => :pulls #routes to list of pulls
7
- get "/users" => "users#index", :as => :users #routes to list of users
8
- get "/user/:id" => "users#show", :as => :user #routes to specific user's contributions
9
- get "/repos" => "repos#index", :as => :repos #route is for the repo filter on the pull request and deploys page
10
- get "/:repo" => "repos#show", :as => :repo #routes to specific repo's stats
4
+ resources :deploys, :only => [:create, :index, :show] # routes to index, show, and to create method
5
+ get "/metrics" => "repos#dashboard", :as => :metrics # routes to list of repos and stats
6
+ get "/pulls" => "pull_requests#index", :as => :pulls # routes to list of pulls
7
+ get "/users" => "users#index", :as => :users # routes to list of users
8
+ get "/user/:id" => "users#show", :as => :user # routes to specific user's contributions
9
+ get "/repos" => "repos#index", :as => :repos # route is for the repo filter on the pull request and deploys page
10
+ get "/:repo" => "repos#show", :as => :repo # routes to specific repo's stats
11
11
  scope "/:repo", :as => :repo do
12
12
  get '/pull/:id' => "pull_requests#show", :as => :pull
13
13
  end
@@ -181,15 +181,13 @@ module Hubstats
181
181
  end
182
182
 
183
183
  def self.route(object, kind, repo_name = nil)
184
+ repo = Hubstats::Repo.where(full_name: repo_name).first
184
185
  if kind == "pulls/comments"
185
- repo = Hubstats::Repo.where(full_name: repo_name).first
186
- Hubstats::Comment.create_or_update(HubHelper.comment_setup(object,repo.id,"PullRequest"))
186
+ create_or_update(object, repo, "PullRequest")
187
187
  elsif kind == "issues/comments"
188
- repo = Hubstats::Repo.where(full_name: repo_name).first
189
- Hubstats::Comment.create_or_update(HubHelper.comment_setup(object,repo.id,"Issue"))
188
+ create_or_update(object, repo, "Issue")
190
189
  elsif kind == "comments"
191
- repo = Hubstats::Repo.where(full_name: repo_name).first
192
- Hubstats::Comment.create_or_update(HubHelper.comment_setup(object,repo.id,"Commit"))
190
+ create_or_update(object, repo, "Commit")
193
191
  elsif kind == "pulls"
194
192
  Hubstats::PullRequest.create_or_update(HubHelper.pull_setup(object))
195
193
  elsif kind == "issues"
@@ -200,6 +198,10 @@ module Hubstats
200
198
  end
201
199
  end
202
200
  end
201
+
202
+ def create_or_update (object, repo, item)
203
+ Hubstats::Comment.create_or_update(HubHelper.comment_setup(object, repo.id, item))
204
+ end
203
205
  end
204
206
  end
205
207
 
@@ -1,3 +1,3 @@
1
1
  module Hubstats
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
@@ -3,6 +3,49 @@ require 'spec_helper'
3
3
  module Hubstats
4
4
  describe DeploysController, :type => :controller do
5
5
  routes { Hubstats::Engine.routes }
6
+
7
+ describe "#index" do
8
+ it "should correctly order all of the deploys" do
9
+ repo = create(:repo, :full_name => "sportngin/ngin")
10
+ deploy1 = create(:deploy, :git_revision => "c1a2b37",
11
+ :repo_id => 101010,
12
+ :deployed_at => "2009-02-03 03:00:00 -0500",
13
+ :user_id => 404040)
14
+ deploy2 = create(:deploy, :git_revision => "kd9c102",
15
+ :repo_id => 101010,
16
+ :deployed_at => "2015-02-03 03:00:00 -0500",
17
+ :user_id => 303030)
18
+ deploy3 = create(:deploy, :git_revision => "owk19sf",
19
+ :repo_id => 101010,
20
+ :deployed_at => "2011-02-03 03:00:00 -0500",
21
+ :user_id => 202020)
22
+ deploy4 = create(:deploy, :git_revision => "owk19sf",
23
+ :repo_id => 101010,
24
+ :deployed_at => "2011-02-03 03:00:00 -0500",
25
+ :user_id => nil)
26
+ deploys_ordered = [deploy2, deploy3, deploy1]
27
+ expect(Hubstats::Deploy).to receive_message_chain("group_by.order_with_timespan.paginate").and_return(deploys_ordered)
28
+ get :index
29
+ expect(response).to have_http_status(200)
30
+ expect(response).to render_template(:index)
31
+ end
32
+ end
33
+
34
+ describe "#show" do
35
+ it "should show the pull requests of the specific deploy" do
36
+ repo = create(:repo, :full_name => "sportngin/ngin")
37
+ deploy = create(:deploy, :git_revision => "c1a2b37",
38
+ :repo_id => 101010,
39
+ :deployed_at => "2009-02-03 03:00:00 -0500")
40
+ pull1 = create(:pull_request, :deploy_id => deploy.id, :repo => repo)
41
+ pull2 = create(:pull_request, :deploy_id => deploy.id, :repo => repo)
42
+ get :show, id: deploy.id
43
+ expect(assigns(:deploy)).to eq(deploy)
44
+ expect(assigns(:pull_requests)).to contain_exactly(pull1, pull2)
45
+ expect(assigns(:deploy).repo_id).to eq(101010)
46
+ end
47
+ end
48
+
6
49
  describe "#create" do
7
50
 
8
51
  before :each do
@@ -98,52 +141,5 @@ module Hubstats
98
141
  expect(response).to have_http_status(400)
99
142
  end
100
143
  end
101
-
102
- describe "#index" do
103
-
104
- before :each do
105
- create(:repo, :full_name => "sportngin/ngin")
106
- end
107
-
108
- it "should correctly order all of the deploys" do
109
- deploy1 = create(:deploy, :git_revision => "c1a2b37",
110
- :repo_id => 101010,
111
- :deployed_at => "2009-02-03 03:00:00 -0500",
112
- :user_id => 404040)
113
- deploy2 = create(:deploy, :git_revision => "kd9c102",
114
- :repo_id => 101010,
115
- :deployed_at => "2015-02-03 03:00:00 -0500",
116
- :user_id => 303030)
117
- deploy3 = create(:deploy, :git_revision => "owk19sf",
118
- :repo_id => 101010,
119
- :deployed_at => "2011-02-03 03:00:00 -0500",
120
- :user_id => 202020)
121
- deploy4 = create(:deploy, :git_revision => "owk19sf",
122
- :repo_id => 101010,
123
- :deployed_at => "2011-02-03 03:00:00 -0500",
124
- :user_id => nil)
125
- deploys_ordered = [deploy2, deploy3, deploy1]
126
- expect(Hubstats::Deploy).to receive_message_chain("group_by.order_with_timespan.paginate").and_return(deploys_ordered)
127
- get :index
128
- expect(response).to have_http_status(200)
129
- expect(response).to render_template(:index)
130
- end
131
- end
132
-
133
- describe "#show" do
134
-
135
- before :each do
136
- create(:repo, :full_name => "sportngin/ngin")
137
- end
138
-
139
- it "should show the pull requests of the specific deploy" do
140
- deploy = create(:deploy, :git_revision => "c1a2b37",
141
- :repo_id => 101010,
142
- :deployed_at => "2009-02-03 03:00:00 -0500")
143
- get :show, id: deploy.id
144
- expect(assigns(:deploy)).to eq(deploy)
145
- expect(assigns(:deploy).repo_id).to eq(101010)
146
- end
147
- end
148
144
  end
149
145
  end
@@ -1,7 +1,46 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Hubstats
4
- RSpec.describe PullRequestsController, :type => :controller do
5
-
4
+ describe PullRequestsController, :type => :controller do
5
+ routes { Hubstats::Engine.routes }
6
+
7
+ describe "#index" do
8
+ it "should correctly order all of the pull requests" do
9
+ user = build(:user)
10
+ repo = build(:repo)
11
+ pull3 = create(:pull_request, :user => user,
12
+ :repo => repo)
13
+ pull1 = create(:pull_request, :user => user,
14
+ :repo => repo)
15
+ pull4 = create(:pull_request, :user => user,
16
+ :repo => repo)
17
+ pull2 = create(:pull_request, :user => user,
18
+ :repo => repo)
19
+ pulls_ordered = [pull3, pull1, pull4, pull2]
20
+ expect(Hubstats::PullRequest).to receive_message_chain("group_by.with_label.state_based_order.paginate").and_return(pulls_ordered)
21
+ get :index
22
+ expect(response).to have_http_status(200)
23
+ expect(response).to render_template(:index)
24
+ end
25
+ end
26
+
27
+ describe "#show" do
28
+ it "should show the comments and deploy of specific pull request" do
29
+ user = build(:user)
30
+ repo = build(:repo)
31
+ pull = create(:pull_request, :user => user,
32
+ :repo => repo,
33
+ :deploy_id => 404040)
34
+ comment1 = create(:comment, :pull_request_id => pull.id)
35
+ comment2 = create(:comment, :pull_request_id => pull.id)
36
+ comment3 = create(:comment, :pull_request_id => pull.id)
37
+ get :show, repo: repo, id: pull.id
38
+ expect(assigns(:pull_request)).to eq(pull)
39
+ expect(assigns(:pull_request).repo_id).to eq(101010)
40
+ expect(assigns(:pull_request).deploy_id).to eq(404040)
41
+ expect(assigns(:comments)).to contain_exactly(comment1, comment2, comment3)
42
+ expect(assigns(:pull_request).user_id).to eq(user.id)
43
+ end
44
+ end
6
45
  end
7
46
  end
@@ -1,7 +1,67 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Hubstats
4
- RSpec.describe ReposController, :type => :controller do
5
-
4
+ describe ReposController, :type => :controller do
5
+ routes { Hubstats::Engine.routes }
6
+
7
+ describe "#index" do
8
+ it "should list all of the repos" do
9
+ repo1 = create(:repo, :id => 101010,
10
+ :name => "silly",
11
+ :full_name => "sportngin/silly")
12
+ repo2 = create(:repo, :id => 202020,
13
+ :name => "funny",
14
+ :full_name => "sportngin/funny")
15
+ repo3 = create(:repo, :id => 303030,
16
+ :name => "loosey",
17
+ :full_name => "sportngin/loosey")
18
+ repo4 = create(:repo, :id => 404040,
19
+ :name => "goosey",
20
+ :full_name => "sportngin/goosey")
21
+ get :index
22
+ expect(assigns(:repos)).to contain_exactly(repo2, repo1, repo3, repo4)
23
+ end
24
+ end
25
+
26
+ describe "#show" do
27
+ it "should show the pull requests and deploys of specific repository" do
28
+ repo = create(:repo, :id => 101010,
29
+ :name => "example",
30
+ :full_name => "sportngin/example",
31
+ :owner_id => 606060)
32
+ pull1 = create(:pull_request, :repo_id => 101010,
33
+ :updated_at => "2015-06-02 19:49:42")
34
+ pull2 = create(:pull_request, :repo_id => 101010,
35
+ :updated_at => "2015-04-21 17:06:31")
36
+ user = create(:user, :id => 606060)
37
+ deploy1 = create(:deploy, :repo_id => 101010)
38
+ deploy2 = create(:deploy, :repo_id => 101010)
39
+ get :show, repo: repo.name
40
+ expect(assigns(:repo)).to eq(repo)
41
+ expect(assigns(:repo).pull_requests).to contain_exactly(pull1, pull2)
42
+ expect(assigns(:repo).deploys).to contain_exactly(deploy1, deploy2)
43
+ expect(assigns(:repo).owner_id).to eq(user.id)
44
+ end
45
+ end
46
+
47
+ describe "#dashboard" do
48
+ it "should list all of the repos and the basic metrics" do
49
+ repo1 = create(:repo, :id => 101010,
50
+ :name => "silly",
51
+ :full_name => "sportngin/silly")
52
+ repo2 = create(:repo, :id => 202020,
53
+ :name => "funny",
54
+ :full_name => "sportngin/funny")
55
+ repo3 = create(:repo, :id => 303030,
56
+ :name => "loosey",
57
+ :full_name => "sportngin/loosey")
58
+ repo4 = create(:repo, :id => 404040,
59
+ :name => "goosey",
60
+ :full_name => "sportngin/goosey")
61
+ expect(Hubstats::Repo).to receive_message_chain("with_id.custom_order.paginate").and_return([repo1, repo2, repo3, repo4])
62
+ get :dashboard
63
+ expect(response).to have_http_status(200)
64
+ end
65
+ end
6
66
  end
7
67
  end
@@ -1,7 +1,35 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Hubstats
4
- RSpec.describe UsersController, :type => :controller do
5
-
4
+ describe UsersController, :type => :controller do
5
+ routes { Hubstats::Engine.routes }
6
+
7
+ describe "#index" do
8
+ it "should show all of the users" do
9
+ user2 = create(:user, :id => 101010, :login => "examplePerson1")
10
+ user1 = create(:user, :id => 202020, :login => "examplePerson2")
11
+ user3 = create(:user, :id => 303030, :login => "examplePerson3")
12
+ user4 = create(:user, :id => 404040, :login => "examplePerson4")
13
+ expect(Hubstats::User).to receive_message_chain("with_id.custom_order.paginate").and_return([user2, user3, user1, user4])
14
+ get :index
15
+ end
16
+ end
17
+
18
+ describe "#show" do
19
+ it "should show the pull requests and deploys of specific user" do
20
+ user = create(:user, :id => 101010, :login => "examplePerson")
21
+ pull1 = create(:pull_request, :user => user, :id => 202020)
22
+ pull2 = create(:pull_request, :user => user, :id => 303030, :repo => pull1.repo)
23
+ deploy1 = create(:deploy, :user_id => 101010)
24
+ deploy2 = create(:deploy, :user_id => 101010)
25
+ comment1 = create(:comment, :user => user)
26
+ comment2 = create(:comment, :user => user)
27
+ get :show, id: "examplePerson"
28
+ expect(assigns(:user)).to eq(user)
29
+ expect(assigns(:user).pull_requests).to contain_exactly(pull1, pull2)
30
+ expect(assigns(:user).deploys).to contain_exactly(deploy1, deploy2)
31
+ expect(assigns(:user).comments).to contain_exactly(comment2, comment1)
32
+ end
33
+ end
6
34
  end
7
35
  end