foreman_statistics 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/jobs/foreman_statistics/trend_counter_job.rb +23 -0
- data/app/views/foreman_statistics/trends/_empty_data.html.erb +0 -1
- data/app/views/foreman_statistics/trends/index.html.erb +2 -11
- data/lib/foreman_statistics/engine.rb +6 -0
- data/lib/foreman_statistics/version.rb +1 -1
- data/webpack/src/Router/StatisticsPage/StatisticsPageSelectors.js +2 -1
- data/webpack/src/Router/StatisticsPage/__tests__/StatisticsPageSelectors.test.js +4 -2
- data/webpack/src/reducers.js +4 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4728ccddc8531f182f6bcf2c29250a3de8dfef2e7dd9987ac9fd782431b3028
|
4
|
+
data.tar.gz: 2227db4f50f237718e189adaab27a128a586f81cc816abdafd96d8d2dbf61cee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4100dd3c03a548a2724d60ba7c7d986899fb12d7b675d565c395dfecfaace8cc03bf5a726f6eda8d6407980bd264c16b929fb83e156036ab3550222345081854
|
7
|
+
data.tar.gz: d25813980f43dd399dd5e39da1ffb19bc31bed171ecee7e4903cba89dbbfd9b8b95355d8518fefd7bdd7bc30a9812a969ad9646c826e69f209bb5baec285cd4e
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ForemanStatistics
|
2
|
+
class TrendCounterJob < ApplicationJob
|
3
|
+
def perform(options = {})
|
4
|
+
start_time = Time.zone.now
|
5
|
+
ForemanStatistics::TrendImporter.update!
|
6
|
+
ensure
|
7
|
+
duration = start_time.is_a?(Time) ? Time.zone.now - start_time : 0
|
8
|
+
self.class.set(wait: [30.minutes - duration, 0].max).perform_later(options)
|
9
|
+
end
|
10
|
+
|
11
|
+
rescue_from(StandardError) do |error|
|
12
|
+
Foreman::Logging.logger('background').error(
|
13
|
+
'Trend Counter Job: '\
|
14
|
+
"Error while creating new data #{error.message}"
|
15
|
+
)
|
16
|
+
raise error # propagate the error to the tasking system to properly report it there
|
17
|
+
end
|
18
|
+
|
19
|
+
def humanized_name
|
20
|
+
_('Trend Counter Job')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -2,6 +2,5 @@
|
|
2
2
|
<div class="row">
|
3
3
|
<div class="stats-well col-md-12">
|
4
4
|
<p><strong><%= _('No data for this trend.') %></strong></p>
|
5
|
-
<div><%= (_("Is the cron job that executes %s enabled?") % "<span class='black'>foreman-rake foreman_statistics:trends:counter</span>").html_safe %></div>
|
6
5
|
</div>
|
7
6
|
</div>
|
@@ -2,15 +2,6 @@
|
|
2
2
|
<% title _("Trends") %>
|
3
3
|
<% title_actions new_link(_("Add Trend Counter")),
|
4
4
|
documentation_button('4.1.3Trends') %>
|
5
|
-
<% if @trends.empty? %>
|
6
|
-
<%= alert :class => 'alert-info', :header => _("No trend counter defined"),
|
7
|
-
:text => (_("To define trend counters, use the Add Trend Counter button.</br> To start collecting trend data, set a cron job to execute 'foreman-rake foreman_statistics:trends:counter' at least every %s minutes.") % Setting[:outofsync_interval]).html_safe %>
|
8
|
-
<% end %>
|
9
|
-
|
10
|
-
<% if @trends.any? and ForemanStatistics::TrendCounter.unconfigured? %>
|
11
|
-
<%= alert :class => 'alert-info', :header => _("No trend counter found"),
|
12
|
-
:text => (_("To start collecting trend data, set a cron job to execute <span class='black'>foreman-rake foreman_statistics:trends:counter</span> at least every %s minutes.") % Setting[:outofsync_interval]).html_safe %>
|
13
|
-
<% end %>
|
14
5
|
|
15
6
|
<table class="<%= table_css_classes 'table-fixed' %>">
|
16
7
|
<thead>
|
@@ -33,7 +24,7 @@
|
|
33
24
|
</tbody>
|
34
25
|
</table>
|
35
26
|
<%= will_paginate_with_info @trends %>
|
36
|
-
<%
|
27
|
+
<% if (latest_counter_time = ForemanStatistics::TrendCounter.maximum(:created_at)) %>
|
37
28
|
<%= _("Last update:") %>
|
38
|
-
<%= date_time_relative(
|
29
|
+
<%= date_time_relative(latest_counter_time) %>
|
39
30
|
<% end %>
|
@@ -79,6 +79,12 @@ module ForemanStatistics
|
|
79
79
|
Apipie.configuration.checksum_path += ['/foreman_statistics/api/']
|
80
80
|
end
|
81
81
|
|
82
|
+
initializer 'foreman_statistics.trend_counter_job' do
|
83
|
+
::Foreman::Application.dynflow.config.on_init do |world|
|
84
|
+
TrendCounterJob.spawn_if_missing(world)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
82
88
|
# Include concerns in this config.to_prepare block
|
83
89
|
config.to_prepare do
|
84
90
|
::ComputeResource.include ForemanStatistics::ComputeResourceDecorations
|
data/webpack/src/reducers.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
1
|
+
import { combineReducers } from 'redux';
|
2
|
+
|
3
|
+
import { reducers as statisticsPageReducers } from './Router/StatisticsPage';
|
2
4
|
|
3
5
|
const reducers = {
|
4
|
-
|
6
|
+
foremanStatistics: combineReducers(statisticsPageReducers),
|
5
7
|
};
|
6
8
|
|
7
9
|
export default reducers;
|
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: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondrej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.87.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.87.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop-minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- app/controllers/foreman_statistics/statistics_controller.rb
|
98
98
|
- app/controllers/foreman_statistics/trends_controller.rb
|
99
99
|
- app/helpers/foreman_statistics/trends_helper.rb
|
100
|
+
- app/jobs/foreman_statistics/trend_counter_job.rb
|
100
101
|
- app/models/concerns/foreman_statistics/compute_resource_decorations.rb
|
101
102
|
- app/models/concerns/foreman_statistics/environment_decorations.rb
|
102
103
|
- app/models/concerns/foreman_statistics/general_setting_decorations.rb
|