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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/github_repo_statistics/github_repo_statistics.rb +57 -9
- data/lib/github_repo_statistics/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d542f1342809e591c429c25f03127747b74b9966915cfd78242d4e8a12576ce1
|
4
|
+
data.tar.gz: e6b1d1380abf5bf896c2e4ebdfb29ac595a0b4111db526ad2e50b3955a9d35ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5a03550f06f6a90b3c9a0912e068bfb446599b56a84190b4ee35b402421fdeefabffbe2f462406973d67bd4b76128493ed6bd56b6614405e3c0c24da113f2b9
|
7
|
+
data.tar.gz: 9e996b48a2b6269fe884853fe64fbaa4edfbf13f9784b17528d1e10d54e517431b36267c5be99e4224d3e82b981f6936d3f0e7f1287048bcee042eb75a88c48b
|
data/Gemfile.lock
CHANGED
@@ -124,7 +124,7 @@ class GithubRepoStatistics
|
|
124
124
|
count += 1 if lines_count > size
|
125
125
|
end
|
126
126
|
|
127
|
-
|
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
|
-
|
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:* #{
|
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
|
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
|
-
|
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
|
-
|
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 -
|
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 -=
|
339
|
+
@begin_time -= 7
|
292
340
|
contribution_message
|
293
341
|
end
|
294
342
|
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.
|
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
|
+
date: 2024-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: date
|