Class: ForemanStatistics::ForemanTrend
- Inherits:
-
Trend
- Object
- ApplicationRecord
- Trend
- ForemanStatistics::ForemanTrend
show all
- Defined in:
- app/models/foreman_statistics/foreman_trend.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Trend
build_trend, humanize_class_name, title_name, #to_param
Class Method Details
.create_values(trendable_type) ⇒ Object
18
19
20
|
# File 'app/models/foreman_statistics/foreman_trend.rb', line 18
def self.create_values(trendable_type)
trendable_type.constantize.all.map { |t| t.trends.create(:fact_value => t.to_label) }
end
|
.model_name ⇒ Object
32
33
34
|
# File 'app/models/foreman_statistics/foreman_trend.rb', line 32
def self.model_name
Trend.model_name
end
|
Instance Method Details
#create_values ⇒ Object
14
15
16
|
# File 'app/models/foreman_statistics/foreman_trend.rb', line 14
def create_values
self.class.create_values(trendable_type)
end
|
#destroy_values ⇒ Object
22
23
24
25
|
# File 'app/models/foreman_statistics/foreman_trend.rb', line 22
def destroy_values
ids = ForemanTrend.where(:trendable_type => trendable_type).pluck(:id)
super(ids)
end
|
#find_hosts ⇒ Object
36
37
38
39
|
# File 'app/models/foreman_statistics/foreman_trend.rb', line 36
def find_hosts
return Host::Managed.none unless trendable
trendable.hosts.order(:name)
end
|
#to_label ⇒ Object
6
7
8
|
# File 'app/models/foreman_statistics/foreman_trend.rb', line 6
def to_label
trendable ? trendable.to_label : trendable_type
end
|
#type_name ⇒ Object
10
11
12
|
# File 'app/models/foreman_statistics/foreman_trend.rb', line 10
def type_name
trendable_type
end
|
#values ⇒ Object
27
28
29
30
|
# File 'app/models/foreman_statistics/foreman_trend.rb', line 27
def values
return ForemanTrend.where(:id => self) if fact_value
ForemanTrend.has_value.where(:trendable_type => trendable_type)
end
|