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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04f2e0c985cab00b83985bacac5d7bd98c093137c29ee2079ab0efa90ed55adc
4
- data.tar.gz: a0f5a576e915cfdc64adb3fa4c6558a44aa92c8aa5cc081d3e007f3e06f6879b
3
+ metadata.gz: e4728ccddc8531f182f6bcf2c29250a3de8dfef2e7dd9987ac9fd782431b3028
4
+ data.tar.gz: 2227db4f50f237718e189adaab27a128a586f81cc816abdafd96d8d2dbf61cee
5
5
  SHA512:
6
- metadata.gz: fa78c311e2d59333e2fb2b43aaaf998805c358919450e5f8e82fdca7d38a725b16b3bbf8373e88d07784fc43c0564bc73d521cc47b20a9268f0c004bd1042055
7
- data.tar.gz: e6d653c21cbb859740aaab5ed524d583ef6d866c6e9a27e6567440047eec4b0d2df8d2fb39efe595848eb41fbc8ebd0616770d9976318ae599502c85b286fe79
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
- <% unless ForemanStatistics::TrendCounter.unconfigured? %>
27
+ <% if (latest_counter_time = ForemanStatistics::TrendCounter.maximum(:created_at)) %>
37
28
  <%= _("Last update:") %>
38
- <%= date_time_relative(ForemanStatistics::TrendCounter.order(:created_at).last.created_at) %>
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
@@ -1,3 +1,3 @@
1
1
  module ForemanStatistics
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -1,4 +1,5 @@
1
- export const selectStatisticsPage = state => state.statisticsPage;
1
+ export const selectStatisticsPage = state =>
2
+ state.foremanStatistics.statisticsPage;
2
3
 
3
4
  export const selectStatisticsMetadata = state =>
4
5
  selectStatisticsPage(state).metadata;
@@ -10,8 +10,10 @@ import {
10
10
  import { statisticsProps } from '../StatisticsPage.fixtures';
11
11
 
12
12
  const state = {
13
- statisticsPage: {
14
- ...statisticsProps,
13
+ foremanStatistics: {
14
+ statisticsPage: {
15
+ ...statisticsProps,
16
+ },
15
17
  },
16
18
  };
17
19
 
@@ -1,7 +1,9 @@
1
- // import { combineReducers } from 'redux';
1
+ import { combineReducers } from 'redux';
2
+
3
+ import { reducers as statisticsPageReducers } from './Router/StatisticsPage';
2
4
 
3
5
  const reducers = {
4
- // foremanStatistics: combineReducers({}),
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.1.3
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-07-22 00:00:00.000000000 Z
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: '0.83'
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: '0.83'
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