github_repo_statistics 2.2.11 → 2.2.13

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
  SHA256:
3
- metadata.gz: 45284d03e5ffb00cb2ed37dc99c775c4cd5270aa82ab8b56e71280d095fdc6f0
4
- data.tar.gz: 14b0536562640711fc5219302932b55eaeae6d5a0ce08caf6fe01f50d3ad86b3
3
+ metadata.gz: 363280a48b1083b29eaceaf52ed9b6fa1f7aed79668f4df3f8eed74706e99652
4
+ data.tar.gz: ec3fb212efb80c2c7332ea0a6c78a3584c940b42ff0c3f1574f71d34615de117
5
5
  SHA512:
6
- metadata.gz: dd4cc361ad9a4e47ace0970e27fc201cfd73e14f2fe54d1be2378331c8e9de80b757c657bab8099633cf0c43cf57f972850e645e68649f19379cd0f6b613ef22
7
- data.tar.gz: 93ac3757ec59d6ce9b433424bbf498635a9c26fa6b89324dcfb1b7164d4395588ed5cc31073b5692ae1014c8e474b374e160699d44904c6366b4181ef7119178
6
+ metadata.gz: 003bf782c6f5878e6ede5c82d142c95ef8ab3381aed6cc8317fec61a539433ca21134ed676ec5d12e3037ac64b2072755190d6eeb628b93d79656d0c637a174e
7
+ data.tar.gz: 6cefa1b4344439d38f6c49ae4e0f0ffcfd4ab4ace41074ce00eeefd1e3bee6058b41d85382e617669e0c14401a00381ad9bc7b28bfd5e89dfc013a97031ab0f7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- github_repo_statistics (2.2.10)
4
+ github_repo_statistics (2.2.12)
5
5
  date
6
6
  faraday-retry
7
7
  google-cloud-bigquery
@@ -31,9 +31,6 @@ class ForceMergeReport
31
31
 
32
32
  weeks = @duration_in_days / 7
33
33
 
34
- require 'pry'
35
- binding.pry
36
-
37
34
  (weekly_pull_requests.keys.sort[-weeks..] || []).each do |month|
38
35
  pull_requests_for_month = weekly_pull_requests[month]
39
36
  # Iterate through pull requests for the current month
@@ -94,6 +91,7 @@ class ForceMergeReport
94
91
  puts " - #{workflow}: #{count}"
95
92
  end
96
93
 
94
+
97
95
  if ENV['BQ_CREDENTIALS']
98
96
  require "google/cloud/bigquery"
99
97
  require "json"
@@ -113,8 +111,8 @@ class ForceMergeReport
113
111
 
114
112
  query = <<~SQL
115
113
  MERGE INTO force_merges AS target
116
- USING (SELECT '#{week}' AS calendar_week) AS source
117
- ON target.calendar_week = source.calendar_week
114
+ USING (SELECT '#{week}' AS calendar_week, '#{@repo}' AS platform) AS source
115
+ ON target.calendar_week = source.calendar_week AND target.platform = source.platform
118
116
  WHEN MATCHED THEN
119
117
  UPDATE SET
120
118
  target.force_merges_count = #{failed_count},
@@ -122,10 +120,11 @@ class ForceMergeReport
122
120
  target.unit_tests_count = #{unit_tests_check},
123
121
  target.size_check_count = #{size_check},
124
122
  target.sonarqube_count = #{sonarqube_check},
125
- target.total_prs = #{total_prs}
123
+ target.total_prs = #{total_prs},
124
+ target.platform = '#{@repo}'
126
125
  WHEN NOT MATCHED THEN
127
- INSERT (calendar_week, force_merges_count, ui_tests_count, unit_tests_count, size_check_count, sonarqube_count, total_prs)
128
- VALUES ('#{week}', #{failed_count}, #{ui_tests_check}, #{unit_tests_check}, #{size_check}, #{sonarqube_check}, #{total_prs});
126
+ INSERT (calendar_week, force_merges_count, ui_tests_count, unit_tests_count, size_check_count, sonarqube_count, total_prs, platform)
127
+ VALUES ('#{week}', #{failed_count}, #{ui_tests_check}, #{unit_tests_check}, #{size_check}, #{sonarqube_check}, #{total_prs}, '#{@repo}');
129
128
  SQL
130
129
 
131
130
  dataset.query(query)
@@ -86,8 +86,39 @@ class ReviewReport
86
86
  puts " Total reviews: #{total_reviews}"
87
87
  puts " Reviews with comments: #{reviews_with_comments}"
88
88
  puts " Change requested reviews: #{change_requested_reviews}"
89
+
90
+
91
+ if ENV['BQ_CREDENTIALS']
92
+ require "google/cloud/bigquery"
93
+ require "json"
94
+ creds = JSON.parse(ENV['BQ_CREDENTIALS'])
95
+ bigquery = Google::Cloud::Bigquery.new(
96
+ project_id: "hellofresh-android",
97
+ credentials: creds
98
+ )
99
+ dataset = bigquery.dataset "github_data"
100
+
101
+ query = <<~SQL
102
+ MERGE INTO pr_reviews AS target
103
+ USING (SELECT '#{week}' AS calendar_week, '#{@repo}' AS platform) AS source
104
+ ON target.calendar_week = source.calendar_week AND target.platform = source.platform
105
+ WHEN MATCHED THEN
106
+ UPDATE SET
107
+ target.change_requested_reviews = #{change_requested_reviews},
108
+ target.reviews_with_comments = #{reviews_with_comments},
109
+ target.total_reviews = #{total_reviews},
110
+ target.average_review_time_hours = #{average_time_hours.round(2)},
111
+ target.total_prs = #{total_count},
112
+ target.platform = '#{@repo}'
113
+ WHEN NOT MATCHED THEN
114
+ INSERT (calendar_week, total_prs, average_review_time_hours, total_reviews, reviews_with_comments, change_requested_reviews, platform)
115
+ VALUES ('#{week}', #{total_count}, #{average_time_hours.round(2)}, #{total_reviews}, #{reviews_with_comments}, #{change_requested_reviews}, '#{@repo}');
116
+ SQL
117
+
118
+ dataset.query(query)
119
+ end
89
120
  else
90
- puts "Month #{week}: No pull requests with reviews."
121
+ puts "#{week}: No pull requests with reviews."
91
122
  end
92
123
  end
93
124
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class GithubRepoStatistics
4
- VERSION = '2.2.11'
4
+ VERSION = '2.2.13'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_repo_statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.11
4
+ version: 2.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serghei Moret
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-03 00:00:00.000000000 Z
11
+ date: 2024-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: date