github_repo_statistics 2.2.13 → 2.2.15

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: 363280a48b1083b29eaceaf52ed9b6fa1f7aed79668f4df3f8eed74706e99652
4
- data.tar.gz: ec3fb212efb80c2c7332ea0a6c78a3584c940b42ff0c3f1574f71d34615de117
3
+ metadata.gz: d542f1342809e591c429c25f03127747b74b9966915cfd78242d4e8a12576ce1
4
+ data.tar.gz: e6b1d1380abf5bf896c2e4ebdfb29ac595a0b4111db526ad2e50b3955a9d35ab
5
5
  SHA512:
6
- metadata.gz: 003bf782c6f5878e6ede5c82d142c95ef8ab3381aed6cc8317fec61a539433ca21134ed676ec5d12e3037ac64b2072755190d6eeb628b93d79656d0c637a174e
7
- data.tar.gz: 6cefa1b4344439d38f6c49ae4e0f0ffcfd4ab4ace41074ce00eeefd1e3bee6058b41d85382e617669e0c14401a00381ad9bc7b28bfd5e89dfc013a97031ab0f7
6
+ metadata.gz: a5a03550f06f6a90b3c9a0912e068bfb446599b56a84190b4ee35b402421fdeefabffbe2f462406973d67bd4b76128493ed6bd56b6614405e3c0c24da113f2b9
7
+ data.tar.gz: 9e996b48a2b6269fe884853fe64fbaa4edfbf13f9784b17528d1e10d54e517431b36267c5be99e4224d3e82b981f6936d3f0e7f1287048bcee042eb75a88c48b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- github_repo_statistics (2.2.12)
4
+ github_repo_statistics (2.2.13)
5
5
  date
6
6
  faraday-retry
7
7
  google-cloud-bigquery
@@ -124,7 +124,7 @@ class GithubRepoStatistics
124
124
  count += 1 if lines_count > size
125
125
  end
126
126
 
127
- puts " *Current total number of code files longer than #{size} lines:* #{count}"
127
+ count
128
128
  end
129
129
 
130
130
  def count_hotspot_lines(files)
@@ -142,7 +142,7 @@ class GithubRepoStatistics
142
142
  count += lines_count
143
143
  end
144
144
 
145
- puts " *Total lines of hotspot code:* #{count}"
145
+ count
146
146
  end
147
147
 
148
148
  def filter_existing_code_files(files)
@@ -234,28 +234,76 @@ class GithubRepoStatistics
234
234
  sorted_occurrences = occurrences.sort_by { |element, count| [-count, element] }
235
235
  contributors = Hash[sorted_occurrences]
236
236
  churn_count = file_team_map.values.map { |value| value[1] }.sum
237
- hotspot_changes_percentage = (churn_count.to_f / total_changes) * 100
237
+ hotspot_changes_percentage = ((churn_count.to_f / total_changes) * 100).round(2)
238
238
  # Filter files based on extension, existence and size
239
239
  filtered_files = filter_files(file_team_map:)
240
240
  filtered_top_touched_files = filtered_files.sort_by { |element, count| [-count.last, element] }
241
241
 
242
+ files_with_single_contributor_percentage = (100 - ((files_changed_by_many_teams.to_f / file_count) * 100)).round(2)
243
+ hotspot_lines = count_hotspot_lines(filtered_files.keys)
244
+ big_files_count = count_big_files(@directory_path)
245
+
246
+
247
+ if ENV['BQ_CREDENTIALS']
248
+ require "google/cloud/bigquery"
249
+ require "json"
250
+ creds = JSON.parse(ENV['BQ_CREDENTIALS'])
251
+ bigquery = Google::Cloud::Bigquery.new(
252
+ project_id: "hellofresh-android",
253
+ credentials: creds
254
+ )
255
+ dataset = bigquery.dataset "github_data"
256
+
257
+ files_with_multiple_contributor = file_team_map.count
258
+ big_files_with_multiple_contributors = filtered_top_touched_files.count
259
+ total_files_changed = uniq_code_files_with_changes.count
260
+
261
+ platform = if @directory_path == 'HelloFresh/HelloFresh/'
262
+ 'ios'
263
+ elsif @directory_path == 'features/legacy/'
264
+ 'android'
265
+ end
266
+
267
+ query = <<~SQL
268
+ INSERT INTO modularization (date, platform, single_contributor_percentage, files_changed_by_many_teams, file_count, cross_teams_count, single_ownership_teams_count, hotspot_changes_percentage, churn_count, total_changes, files_with_multiple_contributor, big_files_with_multiple_contributors, total_files_changed, hotspot_lines, big_files_count)
269
+ VALUES ('#{@begin_time}', '#{platform}', #{files_with_single_contributor_percentage}, #{files_changed_by_many_teams}, #{file_count}, #{cross_teams_count}, #{single_ownership_teams_count}, #{hotspot_changes_percentage}, #{churn_count}, #{total_changes}, #{files_with_multiple_contributor}, #{big_files_with_multiple_contributors}, #{total_files_changed}, #{hotspot_lines}, #{big_files_count});
270
+ SQL
271
+
272
+ dataset.query(query)
273
+
274
+ # delete_query = <<~SQL
275
+ # DELETE FROM modularization
276
+ # WHERE CONCAT(DATE(date), ' ', TIME(date)) NOT IN (
277
+ # SELECT CONCAT(DATE(date), ' ', TIME(date))
278
+ # FROM modularization AS m1
279
+ # WHERE TIME(date) = (
280
+ # SELECT MAX(TIME(date))
281
+ # FROM modularization AS m2
282
+ # WHERE DATE(m1.date) = DATE(m2.date)
283
+ # )
284
+ # );
285
+ # SQL
286
+
287
+ # dataset.query(delete_query)
288
+ end
289
+
242
290
  puts ''
243
291
  puts "*Timeframe:* #{(@begin_time - duration_in_days).strftime('%Y-%m-%d')} to #{@begin_time.strftime('%Y-%m-%d')}"
244
- puts " *Code files with a single contributor:* #{(100 - ((files_changed_by_many_teams.to_f / file_count) * 100)).round(2)}%"
292
+ puts " *Code files with a single contributor:* #{files_with_single_contributor_percentage}%"
245
293
  puts " *Existing files changed by many teams:* #{files_changed_by_many_teams}"
246
294
  puts " *Current existing #{CODE_EXTENSIONS} files:* #{file_count}"
247
295
  puts ' *Cross-Squad Dependency:*'
248
296
  puts " *Contributions by multiple squads to the same files:* #{cross_teams_count}"
249
297
  puts " *Contributions by single squads contributing to single files:* #{single_ownership_teams_count}"
250
- puts " *Hotspot Code Changes:* #{hotspot_changes_percentage.round(2)}%"
298
+ puts " *Hotspot Code Changes:* #{hotspot_changes_percentage}%"
251
299
  puts " *Churn count(commits to files by multiple teams):* #{churn_count}"
252
300
  puts " *Total amount of commits:* #{total_changes}"
253
- count_hotspot_lines(filtered_files.keys)
301
+ puts " *Total lines of hotspot code:* #{hotspot_lines}"
254
302
  puts " *#{CODE_EXTENSIONS} files with multiple contributors:* #{file_team_map.count}"
255
303
  puts " *#{CODE_EXTENSIONS} files exceeding #{BIG_FILE_SIZE} lines with multiple contributors:* #{filtered_top_touched_files.count}"
256
304
  puts " *Total amount of commits to #{CODE_EXTENSIONS} files:* #{total_changes}"
257
305
  puts " *Total #{CODE_EXTENSIONS} files changed:* #{uniq_code_files_with_changes.count}"
258
- count_big_files(@directory_path)
306
+ puts " *Current total number of code files longer than #{BIG_FILE_SIZE} lines:* #{big_files_count}"
259
307
  puts " *Current total of #{CODE_EXTENSIONS} files in the folder:* #{file_count}"
260
308
  puts " *Contributors:* #{contributors}"
261
309
 
@@ -286,9 +334,9 @@ class GithubRepoStatistics
286
334
 
287
335
  return unless @steps.positive?
288
336
 
289
- system("git checkout `git rev-list -1 --before='#{(@begin_time - duration_in_days).strftime('%B %d %Y')}' HEAD`",
337
+ system("git checkout `git rev-list -1 --before='#{(@begin_time - 7).strftime('%B %d %Y')}' HEAD`",
290
338
  %i[out err] => File::NULL)
291
- @begin_time -= duration_in_days
339
+ @begin_time -= 7
292
340
  contribution_message
293
341
  end
294
342
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class GithubRepoStatistics
4
- VERSION = '2.2.13'
4
+ VERSION = '2.2.15'
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.13
4
+ version: 2.2.15
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-11 00:00:00.000000000 Z
11
+ date: 2024-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: date