foreman_statistics 2.0.0 → 2.0.1

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: ebe6e6bb3aad64251f7d191f3bc2cfcd6adca51bdffcb85901957a9074cff7e3
4
- data.tar.gz: d4f425260d58b12cc0888a1b20cea07a4294f1a19cdcd0979ca6a7f2b4927797
3
+ metadata.gz: 755640806f3a97794bb4b955ebb99ed37c522ad48683772b7ab457d45cba3b3b
4
+ data.tar.gz: 7360f71bb358f1c13706bcdacd16e9fb7f36e62dbb6e9314e8cb85de55e034fc
5
5
  SHA512:
6
- metadata.gz: 379d5362616632051dc1e6ac7e9b0919898cf59e5d90ddc4f832876469a6c52ae25a2b4e8aa8f71c409d969b873739342c517b53ad28b286fe6568beeae041af
7
- data.tar.gz: 255b4e780195c26a59bdf7fff704df68a6ee0bdea94b0859857d91f5147562490eefa97032724bc14a3c6e2ba862574970ae71360573aa7a422e0c1f8c73d26f
6
+ metadata.gz: 83f1c16448f74158231ec49156f31c1dcb9f595485b938ae0986e1930e554b7ec7a7832f2e52a8661e80d7834beccb5c282626497ff2ee99266379b9b615f19b
7
+ data.tar.gz: 920cdba7dbdf1df8204485f3b2b5519d98816ac8468efa587aa307618ec49460b5dbdad7c70a6673c738fc48b1743e1d3cefc40097050f9982646090cd390e25
@@ -20,11 +20,12 @@ module ForemanStatistics
20
20
 
21
21
  output = []
22
22
  data = scope.reorder('').group(grouping).count
23
- associations = klass.find_by(id: data.keys)
23
+ associations = klass.where(id: data.keys).to_a
24
24
  data.each do |k, v|
25
25
  output << { label: associations.detect { |a| a.id == k }.to_label, data: v } unless v.zero?
26
- rescue StandardError
27
- logger.info "skipped #{k} as it has has no label"
26
+ rescue StandardError => e
27
+ Rails.logger.info "skipped '#{association} - #{k}' as it has has no label"
28
+ Rails.logger.debug e
28
29
  end
29
30
  output
30
31
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanStatistics
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.0.1'.freeze
3
3
  end
@@ -50,9 +50,19 @@ module ForemanStatistics
50
50
  assert_kind_of Array, stat.calculate
51
51
  end
52
52
 
53
- test 'it should initialize a host counter statistics object' do
54
- stat = Statistics::CountHosts.new(:count_by => :compute_resource)
55
- assert_kind_of Array, stat.calculate
53
+ describe 'CountHosts' do
54
+ test 'initializes a host counter statistics object' do
55
+ stat = Statistics::CountHosts.new(:count_by => :compute_resource)
56
+ assert_kind_of Array, stat.calculate
57
+ end
58
+
59
+ test 'calculates stats by given metric' do
60
+ host = FactoryBot.create(:host, :with_operatingsystem)
61
+ stat = Statistics::CountHosts.new(count_by: :operatingsystem, title: 'OS Distribution').calculate
62
+ _(stat).must_be_instance_of(Array)
63
+ _(stat.first[:data]).must_equal(1)
64
+ _(stat.first[:label]).must_equal(host.operatingsystem.to_label)
65
+ end
56
66
  end
57
67
 
58
68
  context 'with puppet plugin' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Ezr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  requirements: []
224
- rubygems_version: 3.1.6
224
+ rubygems_version: 3.3.4
225
225
  signing_key:
226
226
  specification_version: 4
227
227
  summary: Add Statistics and Trends.