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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 755640806f3a97794bb4b955ebb99ed37c522ad48683772b7ab457d45cba3b3b
|
4
|
+
data.tar.gz: 7360f71bb358f1c13706bcdacd16e9fb7f36e62dbb6e9314e8cb85de55e034fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
@@ -50,9 +50,19 @@ module ForemanStatistics
|
|
50
50
|
assert_kind_of Array, stat.calculate
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
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.
|
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:
|
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.
|
224
|
+
rubygems_version: 3.3.4
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Add Statistics and Trends.
|