Class: Glossarist::GcrStatistics

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/glossarist/gcr_statistics.rb

Class Method Summary collapse

Class Method Details

.count_with(l10ns, attr) ⇒ Object



31
32
33
# File 'lib/glossarist/gcr_statistics.rb', line 31

def self.count_with(l10ns, attr)
  l10ns.count { |l| l.data.send(attr)&.any? }
end

.from_concepts(concepts) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/glossarist/gcr_statistics.rb', line 19

def self.from_concepts(concepts)
  l10ns = concepts.flat_map { |c| c.localizations.to_a }

  new(
    total_concepts: concepts.length,
    languages: l10ns.map(&:language_code).compact.sort.uniq,
    concepts_by_status: l10ns.map(&:entry_status).compact.tally,
    concepts_with_definitions: count_with(l10ns, :definition),
    concepts_with_sources: count_with(l10ns, :sources),
  )
end