Class: ModularizationStatistics::Private::Metrics::Files

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/modularization_statistics/private/metrics/files.rb

Class Method Summary collapse

Class Method Details

.get_file_metrics(metric_name_suffix, tags, files) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/modularization_statistics/private/metrics/files.rb', line 37

def self.get_file_metrics(metric_name_suffix, tags, files)
  [
    GaugeMetric.for("component_files.#{metric_name_suffix}", files.count(&:componentized_file?), tags),
    GaugeMetric.for("packaged_files.#{metric_name_suffix}", files.count(&:packaged_file?), tags),
    GaugeMetric.for("all_files.#{metric_name_suffix}", files.count, tags),
  ]
end

.get_metrics(source_code_files, app_name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/modularization_statistics/private/metrics/files.rb', line 16

def self.get_metrics(source_code_files, app_name)
  all_metrics = T.let([], T::Array[GaugeMetric])
  app_level_tag = Tag.for('app', app_name)

  source_code_files.group_by { |file| file.team_owner&.name }.each do |team_name, files_for_team|
    file_tags = Metrics.tags_for_team(team_name) + [app_level_tag]
    all_metrics += get_file_metrics('by_team', file_tags, files_for_team)
  end

  file_tags = [app_level_tag]
  all_metrics += get_file_metrics('totals', file_tags, source_code_files)
  all_metrics
end