github_repo_statistics 2.3.6 → 2.3.7

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: bcd986a058fd4af9648d2900297d60aaf9a8f53d76f2a58c6a50adbfb40411d0
4
- data.tar.gz: 4e3c39e106d2e4bd0776f4806c0329a49e7279798c48fce3561d342cd47306c8
3
+ metadata.gz: 722258cfcbda685136e97c5b844f38b4da2937dbf3693b5131c628aad5131672
4
+ data.tar.gz: e0377225ed1e088b3eef9ff283ebf254225b36546eae619378f28df4f64cd800
5
5
  SHA512:
6
- metadata.gz: 7fe19b7e6e44588af15ce682f7b2a0a0e3a219d5c4c4d7ba041e33ff57869adc1093f6219681329e16279680cd37913d3bb1815b00eebb97b16309c960cdc975
7
- data.tar.gz: 5636c1a35d16b9cddcd0084bd41423833a3b607d9ebcad0338caa02e62e7a23e17a301e0a1b62ef3283612b75affcd4f113efec6bba8de333be0b0879547d575
6
+ metadata.gz: 37cc51e5dd9c5c40ee4b816fcbfa39e0c288fe6fa17c298890e6f6dbc508923dd094f2bd75969bc906695c69a6e5bec6d36ccdb380b8c1d9a455247b86ce2af4
7
+ data.tar.gz: 355b86a47bb3f55ac5426256a840e3e4a77320a093524f77c93627d73b08c53df3762a5c9c8bab34992f182ba7a74575806442933855858a4f17d245d3986cf2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- github_repo_statistics (2.3.5)
4
+ github_repo_statistics (2.3.7)
5
5
  date
6
6
  faraday-retry
7
7
  google-cloud-bigquery
@@ -227,9 +227,10 @@ class GithubRepoStatistics
227
227
  team.match(/#{TEAM_REGEX}/)[0].upcase
228
228
  end.reject { |e| EXCLUSIONS&.include?(e) }
229
229
 
230
+ teams = calculate_percentile(teams, 90)
231
+
230
232
  total_changes += commit_count
231
233
  all_teams << teams
232
- teams = teams.uniq
233
234
 
234
235
  if teams.count > 1
235
236
  files_changed_by_many_teams += 1
@@ -245,6 +246,30 @@ class GithubRepoStatistics
245
246
  file_team_map]
246
247
  end
247
248
 
249
+ def calculate_percentile(arr, percentile)
250
+ # Count occurrences of each unique element
251
+ counts = arr.each_with_object(Hash.new(0)) { |item, hash| hash[item] += 1 }
252
+
253
+ # Sort elements by their counts in descending order
254
+ sorted_counts = counts.sort_by { |k, v| -v }.to_h
255
+
256
+ # Calculate the cut-off for the percentile
257
+ total_count = arr.size
258
+ cutoff = total_count * (percentile / 100.0)
259
+
260
+ # Select elements that meet the percentile criteria
261
+ selected_elements = []
262
+ cumulative_count = 0
263
+
264
+ sorted_counts.each do |item, count|
265
+ cumulative_count += count
266
+ selected_elements << item
267
+ break if cumulative_count >= cutoff
268
+ end
269
+
270
+ selected_elements
271
+ end
272
+
248
273
  def filter_files(file_team_map:, size: BIG_FILE_SIZE)
249
274
  file_team_map.select do |file_path|
250
275
  next unless File.exist?(file_path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class GithubRepoStatistics
4
- VERSION = '2.3.6'
4
+ VERSION = '2.3.7'
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.3.6
4
+ version: 2.3.7
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-05-28 00:00:00.000000000 Z
11
+ date: 2024-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: date