hubstats 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09f14e805fad77874457b3172ce6280c193e1ae6
4
- data.tar.gz: 3ccc6d0f669631b8cd7cf75a8509d77bddd57c2e
3
+ metadata.gz: 72959e4215249bd0772a2aada53c4ea5a6da6f54
4
+ data.tar.gz: aec75c78a72b43dfffdf886f4e3343c6cc43b95e
5
5
  SHA512:
6
- metadata.gz: 510e5f4169c4520a49945be5f8146c61adbae0b1ef2eeee3e07b352be35fd21488bb05093b793bccb87b26a76f52c3680c79c6c354d31cace08b5eb685eee7e0
7
- data.tar.gz: 83dd4e89f4d1471d968373ef60d4f2cd2b327f2bcd2d8c012ec0d6ea455883912e60b73d1ae44f021f48d35e7aeee8e9fad9b12da1e566c4438ed75270558323
6
+ metadata.gz: 15477112cb8070620567400365515b466c13e275144221a2fd3f283388a122d181651cd12a4211f864ac47fa9b9b4656bba714dd0605b3f69955d48cc6806636
7
+ data.tar.gz: 535d7b0bc4c4dbe1bb9782f5e2cc4046be1dd8fb9ac6b575dfb12be139a555d850b20dd461e7fb3e36f5c848e91a3e34ec01302c7571ba6fededa836eefc5a1f
data/.octopolo.yml ADDED
@@ -0,0 +1,4 @@
1
+ github_repo: sportngin/hubstats
2
+ semantic_versioning: true
3
+ branches_to_keep:
4
+ - master
data/.soyuz.yml ADDED
@@ -0,0 +1,14 @@
1
+ defaults:
2
+ deploy_cmds:
3
+ - gem build hubstats.gemspec
4
+ - gem push *.gem
5
+ before_deploy_cmds:
6
+ - /usr/local/bin/op tag-release
7
+ - sed -i '' -e "s/\".*/\"$(git tag | tail -1 | sed s/v//)\"/" lib/hubstats/version.rb
8
+ - git add lib/hubstats/version.rb
9
+ - git commit -m "Version Bump" && git push
10
+ after_deploy_cmds:
11
+ - rm *.gem
12
+ environments:
13
+ -
14
+ rubygems: {}
@@ -0,0 +1,2 @@
1
+ #### v0.2.0
2
+ #### 2015.02.26.13.51
@@ -5,15 +5,46 @@ $(document).ready(function() {
5
5
  queryParameters = getUrlVars();
6
6
  setUserDefaults(queryParameters);
7
7
 
8
- $("#user-sort-group > .btn").on("click", function(){
9
- updateQueryStringParameter(queryParameters,"order",$(this).attr('id'));
8
+ $("#pulls").on("click", function(){
9
+ toggleOrder(queryParameters,$(this).attr('id'));
10
10
  });
11
11
 
12
+ $("#comments").on("click", function(){
13
+ toggleOrder(queryParameters,$(this).attr('id'));
14
+ });
15
+
16
+ $("#additions").on("click", function(){
17
+ toggleOrder(queryParameters,$(this).attr('id'));
18
+ });
19
+
20
+ $("#deletions").on("click", function(){
21
+ toggleOrder(queryParameters,$(this).attr('id'));
22
+ });
12
23
  });
13
24
 
25
+ function toggleOrder(queryParams, sort_by) {
26
+ if (queryParameters["order"] !== undefined) {
27
+ if (queryParameters["order"] === sort_by+"-desc" ) {
28
+ updateQueryStringParameter(queryParameters,"order",sort_by+"-asc");
29
+ } else {
30
+ updateQueryStringParameter(queryParameters,"order",sort_by+"-desc");
31
+ }
32
+ } else {
33
+ updateQueryStringParameter(queryParameters,"order",sort_by+"-asc");
34
+ }
35
+ }
36
+
14
37
  function setUserDefaults(queryParameters) {
15
- if (queryParameters["order"])
16
- $('#' + queryParameters["order"]).addClass('active');
17
- else
18
- $('#smallest-pulls').addClass('active');
38
+ if (queryParameters["order"]) {
39
+ sort_by = queryParameters["order"].split("-")[0];
40
+ order = queryParameters["order"].split("-")[1];
41
+ if (order === 'asc') {
42
+ $('#'+sort_by+' .octicon').addClass('octicon-arrow-up');
43
+ } else {
44
+ $('#'+sort_by+' .octicon').addClass('octicon-arrow-down');
45
+ }
46
+ }
47
+ else {
48
+ $("#pulls .octicon").addClass('octicon-arrow-down');
49
+ }
19
50
  }
@@ -76,6 +76,10 @@
76
76
  border-radius: 5px;
77
77
  }
78
78
 
79
+ .users {
80
+ margin: 0px 0px 15px 0px;
81
+ }
82
+
79
83
  .pulls > .col, .comments > .col, .users > .col, .repos > .col{
80
84
  padding: 0px 5px 0px 5px;
81
85
  }
@@ -124,4 +128,14 @@
124
128
 
125
129
  .subtle:hover {
126
130
  text-decoration: none;
131
+ }
132
+
133
+ .header {
134
+ text-align: center;
135
+ margin: 0px;
136
+ }
137
+
138
+ a.header:hover {
139
+ cursor: pointer;
140
+ text-decoration: none;
127
141
  }
@@ -28,9 +28,10 @@ module Hubstats
28
28
  user_count: @user_count,
29
29
  pull_count: @pull_count,
30
30
  comment_count: Hubstats::Comment.belonging_to_repo(@repo.id).created_since(@timespan).count(:all),
31
- avg_additions: Hubstats::PullRequest.updated_since(@timespan).belonging_to_repo(@repo.id).average(:additions).to_i,
32
- avg_deletions: Hubstats::PullRequest.updated_since(@timespan).belonging_to_repo(@repo.id).average(:deletions).to_i,
33
- net_additions: Hubstats::PullRequest.updated_since(@timespan).belonging_to_repo(@repo.id).sum(:additions).to_i - Hubstats::PullRequest.updated_since(@timespan).belonging_to_repo(@repo.id).sum(:deletions).to_i
31
+ avg_additions: Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).average(:additions).to_i,
32
+ avg_deletions: Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).average(:deletions).to_i,
33
+ net_additions: Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).sum(:additions).to_i -
34
+ Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).sum(:deletions).to_i
34
35
  }
35
36
  end
36
37
 
@@ -41,10 +42,10 @@ module Hubstats
41
42
  @user_count = Hubstats::User.with_pulls_or_comments(@timespan).only_active.length
42
43
  @stats = {
43
44
  user_count: @user_count,
44
- pull_count: Hubstats::PullRequest.updated_since(@timespan).count(:all),
45
+ pull_count: Hubstats::PullRequest.merged_since(@timespan).count(:all),
45
46
  comment_count: Hubstats::Comment.created_since(@timespan).count(:all),
46
- avg_additions: Hubstats::PullRequest.updated_since(@timespan).average(:additions).to_i,
47
- avg_deletions: Hubstats::PullRequest.updated_since(@timespan).average(:deletions).to_i
47
+ avg_additions: Hubstats::PullRequest.merged_since(@timespan).average(:additions).to_i,
48
+ avg_deletions: Hubstats::PullRequest.merged_since(@timespan).average(:deletions).to_i
48
49
  }
49
50
  end
50
51
  end
@@ -26,12 +26,13 @@ module Hubstats
26
26
  @pull_count = Hubstats::PullRequest.belonging_to_user(@user.id).updated_since(@timespan).count(:all)
27
27
  @comment_count = Hubstats::Comment.belonging_to_user(@user.id).created_since(@timespan).count(:all)
28
28
  @stats = {
29
- pull_count: @pull_count,
29
+ pull_count: Hubstats::PullRequest.belonging_to_user(@user.id).merged_since(@timespan).count(:all),
30
30
  comment_count: @comment_count,
31
31
  review_count: @review ? @review.reviews_count : 0,
32
- avg_additions: Hubstats::PullRequest.updated_since(@timespan).belonging_to_user(@user.id).average(:additions).to_i,
33
- avg_deletions: Hubstats::PullRequest.updated_since(@timespan).belonging_to_user(@user.id).average(:deletions).to_i,
34
- net_additions: Hubstats::PullRequest.updated_since(@timespan).belonging_to_user(@user.id).sum(:additions).to_i - Hubstats::PullRequest.updated_since(@timespan).belonging_to_user(@user.id).sum(:deletions).to_i
32
+ avg_additions: Hubstats::PullRequest.merged_since(@timespan).belonging_to_user(@user.id).average(:additions).to_i,
33
+ avg_deletions: Hubstats::PullRequest.merged_since(@timespan).belonging_to_user(@user.id).average(:deletions).to_i,
34
+ net_additions: Hubstats::PullRequest.merged_since(@timespan).belonging_to_user(@user.id).sum(:additions).to_i -
35
+ Hubstats::PullRequest.merged_since(@timespan).belonging_to_user(@user.id).sum(:deletions).to_i
35
36
  }
36
37
  end
37
38
 
@@ -3,6 +3,7 @@ module Hubstats
3
3
  scope :closed_since, lambda {|time| where("hubstats_pull_requests.closed_at > ?", time) }
4
4
  scope :updated_since, lambda {|time| where("hubstats_pull_requests.updated_at > ?", time) }
5
5
  scope :opened_since, lambda {|time| where("hubstats_pull_requests.created_at > ?", time) }
6
+ scope :merged_since, lambda {|time| where("hubstats_pull_requests.merged").where("hubstats_pull_requests.created_at > ?", time) }
6
7
  scope :belonging_to_repo, lambda {|repo_id| where(repo_id: repo_id)}
7
8
  scope :belonging_to_user, lambda {|user_id| where(user_id: user_id)}
8
9
  scope :belonging_to_repos, lambda {|repo_id| where(repo_id: repo_id.split(',')) if repo_id}
@@ -64,6 +65,5 @@ module Hubstats
64
65
  scoped
65
66
  end
66
67
  end
67
-
68
68
  end
69
69
  end
@@ -3,16 +3,19 @@ module Hubstats
3
3
 
4
4
  scope :with_id, lambda {|user_id| where(id: user_id.split(',')) if user_id}
5
5
 
6
+ scope :merged_pulls, lambda {
7
+ where("hubstats_pull_requests.merged = '1'")
8
+ }
6
9
  scope :pull_requests_count, lambda { |time|
7
10
  select("hubstats_users.id as user_id")
8
11
  .select("COUNT(DISTINCT hubstats_pull_requests.id) AS pull_request_count")
9
- .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND hubstats_pull_requests.closed_at > '#{time}'")
12
+ .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND hubstats_pull_requests.created_at > '#{time}'")
10
13
  .group("hubstats_users.id")
11
14
  }
12
15
  scope :pull_requests_count_by_repo, lambda { |time,repo_id|
13
16
  select("hubstats_users.id as user_id")
14
17
  .select("COUNT(DISTINCT hubstats_pull_requests.id) AS pull_request_count")
15
- .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND hubstats_pull_requests.closed_at > '#{time}' AND hubstats_pull_requests.repo_id = '#{repo_id}'")
18
+ .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND hubstats_pull_requests.created_at > '#{time}' AND hubstats_pull_requests.repo_id = '#{repo_id}'")
16
19
  .group("hubstats_users.id")
17
20
  }
18
21
  scope :comments_count, lambda { |time|
@@ -31,7 +34,7 @@ module Hubstats
31
34
  select("hubstats_users.id as user_id")
32
35
  .select("COUNT(DISTINCT hubstats_pull_requests.id) as reviews_count")
33
36
  .joins("LEFT JOIN hubstats_comments ON hubstats_comments.user_id = hubstats_users.id AND hubstats_comments.created_at > '#{time}'")
34
- .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.id = hubstats_comments.pull_request_id AND hubstats_pull_requests.closed_at > '#{time}'")
37
+ .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.id = hubstats_comments.pull_request_id AND hubstats_pull_requests.created_at > '#{time}'")
35
38
  .where("hubstats_pull_requests.user_id != hubstats_users.id")
36
39
  .group("hubstats_users.id")
37
40
  }
@@ -40,28 +43,28 @@ module Hubstats
40
43
  select("hubstats_users.id as user_id")
41
44
  .select("ROUND(IFNULL(AVG(hubstats_pull_requests.additions),0)) AS average_additions")
42
45
  .select("ROUND(IFNULL(AVG(hubstats_pull_requests.deletions),0)) AS average_deletions")
43
- .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND hubstats_pull_requests.closed_at > '#{time}'")
46
+ .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND hubstats_pull_requests.created_at > '#{time}'")
44
47
  .group("hubstats_users.id")
45
48
  }
46
49
 
47
50
  scope :pull_and_comment_count, lambda { |time|
48
51
  select("hubstats_users.*, pull_request_count, comment_count")
49
- .joins("LEFT JOIN (#{pull_requests_count(time).to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
52
+ .joins("LEFT JOIN (#{pull_requests_count(time).merged_pulls.to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
50
53
  .joins("LEFT JOIN (#{comments_count(time).to_sql}) AS comments ON comments.user_id = hubstats_users.id")
51
54
  .group("hubstats_users.id")
52
55
  }
53
56
 
54
57
  scope :pull_and_comment_count_by_repo, lambda { |time,repo_id|
55
58
  select("hubstats_users.*, pull_request_count, comment_count")
56
- .joins("LEFT JOIN (#{pull_requests_count_by_repo(time,repo_id).to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
59
+ .joins("LEFT JOIN (#{pull_requests_count_by_repo(time,repo_id).merged_pulls.to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
57
60
  .joins("LEFT JOIN (#{comments_count_by_repo(time,repo_id).to_sql}) AS comments ON comments.user_id = hubstats_users.id")
58
61
  .group("hubstats_users.id")
59
62
  }
60
63
 
61
64
  scope :with_all_metrics, lambda { |time|
62
65
  select("hubstats_users.*, pull_request_count, comment_count, average_additions, average_deletions")
63
- .joins("LEFT JOIN (#{averages(time).to_sql}) AS averages ON averages.user_id = hubstats_users.id")
64
- .joins("LEFT JOIN (#{pull_requests_count(time).to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
66
+ .joins("LEFT JOIN (#{averages(time).merged_pulls.to_sql}) AS averages ON averages.user_id = hubstats_users.id")
67
+ .joins("LEFT JOIN (#{pull_requests_count(time).merged_pulls.to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
65
68
  .joins("LEFT JOIN (#{comments_count(time).to_sql}) AS comments ON comments.user_id = hubstats_users.id")
66
69
  .group("hubstats_users.id")
67
70
  }
@@ -98,17 +101,23 @@ module Hubstats
98
101
  end
99
102
  end
100
103
 
101
- def self.custom_order(order)
102
-
103
- case order
104
- when 'largest-pulls'
105
- order("average_additions = 0, average_additions DESC")
106
- when 'most-active'
107
- order("(pull_request_count)*2 + (comment_count) DESC")
108
- when 'least-active'
109
- order("(pull_request_count)*2 + (comment_count) ASC")
110
- else
111
- order("average_additions = 0, average_additions ASC")
104
+ def self.custom_order(order_params)
105
+ if order_params
106
+ order = order_params.include?('asc') ? "ASC" : "DESC"
107
+ case order_params.split('-').first
108
+ when 'pulls'
109
+ order("pull_request_count #{order}")
110
+ when 'comments'
111
+ order("pull_request_count #{order}")
112
+ when 'additions'
113
+ order("average_additions #{order}")
114
+ when 'deletions'
115
+ order("average_deletions #{order}")
116
+ else
117
+ order("pull_request_count #{order}")
118
+ end
119
+ else
120
+ order("pull_request_count DESC")
112
121
  end
113
122
  end
114
123
 
@@ -8,11 +8,13 @@
8
8
  <%= link_to pull.title, repo_pull_path({:repo => pull.repo.name, :id => pull.id}) %>
9
9
  </h4>
10
10
  by <%= link_to pull.user.login, user_path(pull.user) %>
11
- <% if pull.state == 'closed' %>
11
+ <% if pull.merged == '1'%>
12
+ <%= "merged #{time_ago_in_words(pull.created_at)} ago "%>
13
+ <% elsif pull.state == 'closed' %>
12
14
  <%= "closed #{time_ago_in_words(pull.closed_at)} ago "%>
13
- <% else %>
15
+ <% else %>
14
16
  <%= "opened #{time_ago_in_words(pull.created_at)} ago "%>
15
- <% end %>
17
+ <% end %>
16
18
  </div>
17
19
 
18
20
  <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" >
@@ -13,11 +13,13 @@
13
13
  <% end %>
14
14
  <br>
15
15
  by <%= link_to pull.user.login, user_path(pull.user) %>
16
- <% if pull.state == 'closed' %>
16
+ <% if pull.merged == '1'%>
17
+ <%= "merged #{time_ago_in_words(pull.created_at)} ago "%>
18
+ <% elsif pull.state == 'closed' %>
17
19
  <%= "closed #{time_ago_in_words(pull.closed_at)} ago "%>
18
- <% else %>
20
+ <% else %>
19
21
  <%= "opened #{time_ago_in_words(pull.created_at)} ago "%>
20
- <% end %>
22
+ <% end %>
21
23
  </div>
22
24
 
23
25
  <div class="col-lg-2 col-md-2 col-sm-2" >
@@ -15,31 +15,27 @@
15
15
  </h4>
16
16
  </div>
17
17
  <div class="col-lg-2 col-md-2 col-sm-2">
18
- <div class="pull-right">
18
+ <div class="text-center">
19
19
  <span class="text-large"><%= user.pull_request_count %></span>
20
20
  <span class="mega-octicon octicon-git-pull-request"></span>
21
- <p class="text-small text-center"> pulls </p>
22
21
  </div>
23
22
  </div>
24
23
  <div class="col-lg-2 col-md-2 col-sm-2">
25
- <div class="pull-right">
24
+ <div class="text-center">
26
25
  <span class="text-large"><%= user.comment_count %></span>
27
26
  <span class="mega-octicon octicon-comment"></span>
28
- <p class="text-small text-center"> comments </p>
29
27
  </div>
30
28
  </div>
31
29
  <div class="col-lg-2 col-md-2 col-sm-2">
32
- <div class="pull-right">
30
+ <div class="text-center">
33
31
  <span class="text-large"><%= user.average_additions %></span>
34
32
  <span class="mega-octicon octicon-plus"></span>
35
- <p class="text-small text-center"> additions </p>
36
33
  </div>
37
34
  </div>
38
35
  <div class="col-lg-2 col-md-2 col-sm-2">
39
- <div class="pull-right">
36
+ <div class="text-center">
40
37
  <span class="text-large"><%= user.average_deletions %></span>
41
38
  <span class="mega-octicon octicon-dash"></span>
42
- <p class="text-small text-center"> deletions </p>
43
39
  </div>
44
40
  </div>
45
41
 
@@ -1,5 +1,21 @@
1
1
  <% if @users.length > 0 %>
2
2
  <div class="users">
3
+ <div class="row single-user header">
4
+ <div class="col-lg-4 col-md-4 col-sm-4">
5
+ </div>
6
+ <div class="col-lg-2 col-md-2 col-sm-2">
7
+ <a class="header desc" id="pulls"> Pulls <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="comments"> Comments <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="additions"> Additions <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="deletions"> Deletions <span class="octicon"></span></a>
17
+ </div>
18
+ </div>
3
19
  <%= render partial: 'hubstats/partials/user', collection: @users, as: :user %>
4
20
  </div>
5
21
  <% else %>
@@ -13,22 +13,6 @@
13
13
 
14
14
  <div class="col-lg-9">
15
15
 
16
- <div id="user-sort-group" class="btn-group" data-toggle="buttons">
17
- <label class="btn btn-default" id='smallest-pulls'>
18
- <input type="radio" name="sort"> Smallest Pulls
19
- </label>
20
- <label class="btn btn-default" id='largest-pulls'>
21
- <input type="radio" name="sort"> Largest Pulls
22
- </label>
23
- <label class="btn btn-default" id='most-active'>
24
- <input type="radio" name="sort"> Most Active
25
- </label>
26
- <label class="btn btn-default" id='least-active'>
27
- <input type="radio" name="sort"> Least Active
28
- </label>
29
- </div>
30
-
31
-
32
16
  <%= render 'hubstats/tables/users' %>
33
17
 
34
18
  <div class="text-center">
@@ -1,3 +1,3 @@
1
1
  module Hubstats
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Hursh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-13 00:00:00.000000000 Z
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -129,10 +129,12 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
- - ".automation.yml"
133
132
  - ".gitignore"
133
+ - ".octopolo.yml"
134
134
  - ".rspec"
135
+ - ".soyuz.yml"
135
136
  - ".travis.yml"
137
+ - CHANGELOG.markdown
136
138
  - Gemfile
137
139
  - MIT-LICENSE
138
140
  - README.rdoc
@@ -292,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
294
  version: '0'
293
295
  requirements: []
294
296
  rubyforge_project:
295
- rubygems_version: 2.2.2
297
+ rubygems_version: 2.4.5
296
298
  signing_key:
297
299
  specification_version: 4
298
300
  summary: Github Statistics
data/.automation.yml DELETED
@@ -1 +0,0 @@
1
- github_repo: sportngin/hubstats