hubstats 0.11.1 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +3 -21
- data/app/controllers/hubstats/teams_controller.rb +1 -1
- data/app/controllers/hubstats/users_controller.rb +1 -1
- data/app/models/hubstats/comment.rb +6 -1
- data/app/models/hubstats/pull_request.rb +2 -2
- data/app/models/hubstats/repo.rb +2 -2
- data/app/models/hubstats/team.rb +1 -1
- data/app/models/hubstats/user.rb +8 -7
- data/lib/hubstats/github_api.rb +9 -6
- data/lib/hubstats/version.rb +1 -1
- data/lib/tasks/populate_task.rake +6 -1
- data/spec/lib/hubstats/events_handler_spec.rb +10 -0
- data/test/dummy/config/database.yml +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fc079b6e63d5a5fc7ee4503e35820ea54e09424
|
4
|
+
data.tar.gz: 46597aad8e5b14d15754cd6e4e04285e479f6b41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 353bd5e9cea0e12d4fd12b28fda94093936c854638ecf660f1f854651ce9a82ea3f5693eb5cb29771b995209953a6bad131004946268a700709db3554b76cc06
|
7
|
+
data.tar.gz: 5da5b406669dff022fab684b6f9cef6098793176f2b423ffa77ced20580accf6609555389fa47a72a3791a7629095f009b26d69520ffad11f9e2bbcf9681a105
|
data/CHANGELOG.markdown
CHANGED
@@ -1,21 +1,3 @@
|
|
1
|
-
#### v0.11.
|
2
|
-
|
3
|
-
|
4
|
-
> Emma Sax: Unknown User: https://github.com/sportngin/hubstats/pull/123
|
5
|
-
|
6
|
-
#### v0.11.0
|
7
|
-
* Hubstats does not need to show data for deployments
|
8
|
-
|
9
|
-
> Emma Sax: Unknown User: https://github.com/sportngin/hubstats/pull/121
|
10
|
-
|
11
|
-
#### v0.10.0
|
12
|
-
* Show list of QA Signoffs on User's show page
|
13
|
-
|
14
|
-
> Emma Sax: Unknown User: https://github.com/sportngin/hubstats/pull/120
|
15
|
-
|
16
|
-
#### v0.9.5
|
17
|
-
* Linking Today button in Hubstats datepicker
|
18
|
-
|
19
|
-
> Emma Sax: Unknown User: https://github.com/sportngin/hubstats/pull/116
|
20
|
-
|
21
|
-
#### v0.9.4
|
1
|
+
#### v0.11.4
|
2
|
+
#### v0.11.3
|
3
|
+
#### v0.11.2
|
@@ -33,7 +33,7 @@ module Hubstats
|
|
33
33
|
@team = Hubstats::Team.where(id: params[:id]).first
|
34
34
|
@pull_requests = Hubstats::PullRequest.belonging_to_team(@team.id).merged_in_date_range(@start_date, @end_date).order("updated_at DESC").limit(20)
|
35
35
|
@pull_count = Hubstats::PullRequest.belonging_to_team(@team.id).merged_in_date_range(@start_date, @end_date).count(:all)
|
36
|
-
@users = @team.users.where(
|
36
|
+
@users = @team.users.where.not(login: Hubstats.config.github_config["ignore_users_list"] || []).order("login ASC").distinct
|
37
37
|
@active_user_count = @users.length
|
38
38
|
@comment_count = Hubstats::Comment.belonging_to_team(@users.pluck(:id)).created_in_date_range(@start_date, @end_date).count(:all)
|
39
39
|
repos_pr = @pull_requests.pluck(:repo_id)
|
@@ -14,7 +14,7 @@ module Hubstats
|
|
14
14
|
@users = Hubstats::User.where(id: params[:id].split(",")).order("login ASC")
|
15
15
|
else
|
16
16
|
@users = Hubstats::User.with_all_metrics(@start_date, @end_date)
|
17
|
-
.where(
|
17
|
+
.where.not(login: Hubstats.config.github_config["ignore_users_list"] || [])
|
18
18
|
.with_id(params[:users])
|
19
19
|
.custom_order(params[:order])
|
20
20
|
.paginate(:page => params[:page], :per_page => 15)
|
@@ -5,7 +5,7 @@ module Hubstats
|
|
5
5
|
|
6
6
|
# Various checks that can be used to filter and find info about comments.
|
7
7
|
scope :created_in_date_range, lambda {|start_date, end_date| where("hubstats_comments.created_at BETWEEN ? AND ?", start_date, end_date)}
|
8
|
-
scope :ignore_comments_by, lambda {|user_ids| where(
|
8
|
+
scope :ignore_comments_by, lambda {|user_ids| where.not(user_id: user_ids || []) if user_ids}
|
9
9
|
scope :belonging_to_pull_request, lambda {|pull_request_id| where(pull_request_id: pull_request_id)}
|
10
10
|
scope :belonging_to_user, lambda {|user_id| where(user_id: user_id)}
|
11
11
|
scope :belonging_to_team, lambda {|user_ids| where(user_id: user_ids) if user_ids}
|
@@ -32,6 +32,11 @@ module Hubstats
|
|
32
32
|
def self.create_or_update(github_comment)
|
33
33
|
github_comment = github_comment.to_h.with_indifferent_access if github_comment.respond_to? :to_h
|
34
34
|
|
35
|
+
unless github_comment[:user_id]
|
36
|
+
Rails.logger.warn "Found comment with no user, ignoring. GitHub comment ID: #{github_comment[:id]}"
|
37
|
+
return nil
|
38
|
+
end
|
39
|
+
|
35
40
|
user = Hubstats::User.create_or_update(github_comment[:user])
|
36
41
|
github_comment[:user_id] = user.id
|
37
42
|
|
@@ -7,9 +7,9 @@ module Hubstats
|
|
7
7
|
scope :closed_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.closed_at BETWEEN ? AND ?", start_date, end_date)}
|
8
8
|
scope :updated_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.updated_at BETWEEN ? AND ?", start_date, end_date)}
|
9
9
|
scope :created_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.created_at BETWEEN ? AND ?", start_date, end_date)}
|
10
|
-
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)}
|
10
|
+
scope :merged_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.merged = ?", true).where("hubstats_pull_requests.merged_at BETWEEN ? AND ?", start_date, end_date)}
|
11
11
|
scope :created_since, lambda {|days| where("hubstats_pull_requests.created_at > ?", Date.today - days)}
|
12
|
-
scope :ignore_pulls_by, lambda {|user_ids| where(
|
12
|
+
scope :ignore_pulls_by, lambda {|user_ids| where.not(user_id: user_ids || []) if user_ids}
|
13
13
|
scope :belonging_to_repo, lambda {|repo_id| where(repo_id: repo_id)}
|
14
14
|
scope :belonging_to_team, lambda {|team_id| where(team_id: team_id)}
|
15
15
|
scope :belonging_to_user, lambda {|user_id| where(user_id: user_id)}
|
data/app/models/hubstats/repo.rb
CHANGED
@@ -42,7 +42,7 @@ module Hubstats
|
|
42
42
|
scope :pull_requests_count, lambda {|start_date, end_date|
|
43
43
|
select("hubstats_repos.id as repo_id")
|
44
44
|
.select("IFNULL(COUNT(DISTINCT hubstats_pull_requests.id),0) AS pull_request_count")
|
45
|
-
.joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.repo_id = hubstats_repos.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND hubstats_pull_requests.merged =
|
45
|
+
.joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.repo_id = hubstats_repos.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND hubstats_pull_requests.merged = ?", start_date, end_date, true]))
|
46
46
|
.group("hubstats_repos.id")
|
47
47
|
}
|
48
48
|
|
@@ -56,7 +56,7 @@ module Hubstats
|
|
56
56
|
select("hubstats_repos.id as repo_id")
|
57
57
|
.select("ROUND(IFNULL(AVG(hubstats_pull_requests.additions),0)) AS average_additions")
|
58
58
|
.select("ROUND(IFNULL(AVG(hubstats_pull_requests.deletions),0)) AS average_deletions")
|
59
|
-
.joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.repo_id = hubstats_repos.id AND hubstats_pull_requests.merged =
|
59
|
+
.joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.repo_id = hubstats_repos.id AND hubstats_pull_requests.merged = ? AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?)", true, start_date, end_date]))
|
60
60
|
.group("hubstats_repos.id")
|
61
61
|
}
|
62
62
|
|
data/app/models/hubstats/team.rb
CHANGED
@@ -28,7 +28,7 @@ module Hubstats
|
|
28
28
|
scope :pull_requests_count, lambda {|start_date, end_date|
|
29
29
|
select("hubstats_teams.id as team_id")
|
30
30
|
.select("IFNULL(COUNT(DISTINCT hubstats_pull_requests.id),0) AS pull_request_count")
|
31
|
-
.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 =
|
31
|
+
.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 = ?", start_date, end_date, true]))
|
32
32
|
.group("hubstats_teams.id")
|
33
33
|
}
|
34
34
|
|
data/app/models/hubstats/user.rb
CHANGED
@@ -3,11 +3,12 @@ module Hubstats
|
|
3
3
|
|
4
4
|
# Various checks that can be used to filter and find info about users.
|
5
5
|
scope :with_id, lambda {|user_id| where(id: user_id.split(',')) if user_id}
|
6
|
-
scope :only_active, -> {
|
7
|
-
scope :is_developer, -> {
|
8
|
-
scope :is_reviewer, -> {
|
6
|
+
scope :only_active, -> { not_ignored.having("comment_count > 0 OR pull_request_count > 0 OR deploy_count > 0") }
|
7
|
+
scope :is_developer, -> { not_ignored.having("pull_request_count > 0") }
|
8
|
+
scope :is_reviewer, -> { not_ignored.having("comment_count > 0") }
|
9
9
|
scope :with_contributions, lambda {|start_date, end_date, repo_id| with_all_metrics_repos(start_date, end_date, repo_id) if repo_id}
|
10
|
-
scope :ignore_users_ids, -> { where(
|
10
|
+
scope :ignore_users_ids, -> { where(login: Hubstats.config.github_config["ignore_users_list"] || []).pluck(:id) }
|
11
|
+
scope :not_ignored, -> { where.not(login: Hubstats.config.github_config["ignore_users_list"] || []) }
|
11
12
|
|
12
13
|
# Public - Counts all of the deploys for selected user that occurred between the start_date and end_date.
|
13
14
|
#
|
@@ -57,7 +58,7 @@ module Hubstats
|
|
57
58
|
scope :pull_requests_count, lambda {|start_date, end_date|
|
58
59
|
select("hubstats_users.id as user_id")
|
59
60
|
.select("IFNULL(COUNT(DISTINCT hubstats_pull_requests.id),0) AS pull_request_count")
|
60
|
-
.joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND hubstats_pull_requests.merged =
|
61
|
+
.joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND hubstats_pull_requests.merged = ?", start_date, end_date, true]))
|
61
62
|
.group("hubstats_users.id")
|
62
63
|
}
|
63
64
|
|
@@ -124,7 +125,7 @@ module Hubstats
|
|
124
125
|
scope :pull_requests_count_by_repo, lambda {|start_date, end_date, repo_id|
|
125
126
|
select("hubstats_users.id as user_id")
|
126
127
|
.select("IFNULL(COUNT(DISTINCT hubstats_pull_requests.id),0) AS pull_request_count")
|
127
|
-
.joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND (hubstats_pull_requests.repo_id LIKE ?) AND hubstats_pull_requests.merged =
|
128
|
+
.joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND (hubstats_pull_requests.repo_id LIKE ?) AND hubstats_pull_requests.merged = ?", start_date, end_date, repo_id, true]))
|
128
129
|
.group("hubstats_users.id")
|
129
130
|
}
|
130
131
|
|
@@ -155,7 +156,7 @@ module Hubstats
|
|
155
156
|
select("hubstats_users.id as user_id")
|
156
157
|
.select("SUM(IFNULL(hubstats_pull_requests.additions, 0)) AS additions")
|
157
158
|
.select("SUM(IFNULL(hubstats_pull_requests.deletions, 0)) AS deletions")
|
158
|
-
.joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND hubstats_pull_requests.merged =
|
159
|
+
.joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?) AND hubstats_pull_requests.merged = ?", start_date, end_date, true]))
|
159
160
|
.group("hubstats_users.id")
|
160
161
|
}
|
161
162
|
|
data/lib/hubstats/github_api.rb
CHANGED
@@ -44,7 +44,7 @@ module Hubstats
|
|
44
44
|
octo = client({:auto_paginate => true})
|
45
45
|
octo.paginate(path, options) do |data, last_response|
|
46
46
|
last_response.data.each{|v| route(v,kind,repo_name)}.clear
|
47
|
-
wait_limit(1,octo.rate_limit)
|
47
|
+
wait_limit(false, 1, octo.rate_limit)
|
48
48
|
end.each{|v| route(v,kind,repo_name)}.clear
|
49
49
|
end
|
50
50
|
|
@@ -82,7 +82,7 @@ module Hubstats
|
|
82
82
|
pr = client.pull_request(repo.full_name, pull.number)
|
83
83
|
Hubstats::PullRequest.create_or_update(HubHelper.pull_setup(pr))
|
84
84
|
end
|
85
|
-
wait_limit(grab_size,client.rate_limit)
|
85
|
+
wait_limit(false, grab_size, client.rate_limit)
|
86
86
|
end
|
87
87
|
puts "All Pull Requests are up to date"
|
88
88
|
rescue Faraday::ConnectionFailed
|
@@ -115,7 +115,7 @@ module Hubstats
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
118
|
-
wait_limit(grab_size,client.rate_limit)
|
118
|
+
wait_limit(false, grab_size, client.rate_limit)
|
119
119
|
puts "All teams are up to date"
|
120
120
|
rescue Faraday::ConnectionFailed
|
121
121
|
puts "Connection Timeout, restarting team updating"
|
@@ -270,9 +270,12 @@ module Hubstats
|
|
270
270
|
# rate_limit - the amount of time to wait to grab data
|
271
271
|
#
|
272
272
|
# Returns - nothing
|
273
|
-
def self.wait_limit(grab_size, rate_limit)
|
274
|
-
|
275
|
-
|
273
|
+
def self.wait_limit(force, grab_size=nil, rate_limit=nil)
|
274
|
+
rate_limit = client.rate_limit unless rate_limit
|
275
|
+
grab_size = 250 unless grab_size
|
276
|
+
|
277
|
+
if force || rate_limit.remaining < grab_size
|
278
|
+
puts "We don't want to hit the GitHub wait limit; waiting #{Time.at(rate_limit.resets_in).utc.strftime("%H:%M:%S")} to get more"
|
276
279
|
sleep(rate_limit.resets_in)
|
277
280
|
end
|
278
281
|
end
|
data/lib/hubstats/version.rb
CHANGED
@@ -15,11 +15,16 @@ namespace :hubstats do
|
|
15
15
|
|
16
16
|
desc "Updates which repos hubstats tracks"
|
17
17
|
task :update_repos => :environment do
|
18
|
-
Hubstats::GithubAPI.get_repos.
|
18
|
+
Hubstats::GithubAPI.get_repos.each_with_index do |repo, index|
|
19
19
|
unless Hubstats::Repo.where(full_name: repo.full_name).first
|
20
20
|
Rake::Task["hubstats:populate:setup_repo"].execute({repo: repo})
|
21
21
|
end
|
22
|
+
|
23
|
+
if index % 10 == 0
|
24
|
+
Hubstats::GithubAPI.wait_limit(true)
|
25
|
+
end
|
22
26
|
end
|
27
|
+
|
23
28
|
puts "Finished with initial updating, grabbing extra info about pull requests"
|
24
29
|
Rake::Task["hubstats:populate:update_pulls"].execute
|
25
30
|
puts "Finished grabbing info about pull requests, populating teams"
|
@@ -70,6 +70,16 @@ module Hubstats
|
|
70
70
|
allow(Hubstats::User).to receive_message_chain(:create_or_update).and_return(user)
|
71
71
|
expect(ehandler.route(payload, payload[:type]).class).to eq(Hubstats::Comment)
|
72
72
|
end
|
73
|
+
|
74
|
+
it 'should successfully creates_or_updates the event even if the user_id is missing' do
|
75
|
+
ehandler = Hubstats::EventsHandler.new()
|
76
|
+
payload = build(:comment_payload_hash, :user => {:login=>"hermina", :id=>0, :role=>"User"},
|
77
|
+
:comment => {"id"=>194761, "body"=>"Quidem ea minus ut odio optio.",
|
78
|
+
"kind"=>"Issue", "repo_id"=>101010,
|
79
|
+
"created_at" => Date.today, "updated_at" => Date.today})
|
80
|
+
allow(Hubstats::User).to receive_message_chain(:create_or_update).and_return(user)
|
81
|
+
expect(ehandler.route(payload, payload[:type])).to be_nil
|
82
|
+
end
|
73
83
|
end
|
74
84
|
|
75
85
|
context "TeamEvent" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elliot Hursh
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -407,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
407
407
|
version: '0'
|
408
408
|
requirements: []
|
409
409
|
rubyforge_project:
|
410
|
-
rubygems_version: 2.
|
410
|
+
rubygems_version: 2.6.13
|
411
411
|
signing_key:
|
412
412
|
specification_version: 4
|
413
413
|
summary: Github Statistics
|