Class: IevkitViews::ActionReport

Inherits:
Report
  • Object
show all
Defined in:
app/services/ievkit_views/action_report.rb

Instance Attribute Summary

Attributes inherited from Report

#datas, #result, #search

Instance Method Summary collapse

Methods inherited from Report

#errors, #initialize, #search_for, #sort_datas, #sum_report, #sum_report_for_tests

Methods included from ApplicationHelper

#badge_count, #get_icon, #get_icon_title

Constructor Details

This class inherits a constructor from IevkitViews::Report

Instance Method Details

#collections(type = 'line') ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/services/ievkit_views/action_report.rb', line 60

def collections(type = 'line')
  datas = []
  return datas unless @report['collections'].present?
  collections = []
  @report['collections'].each{ |el|
    collections << el['objects'] if el['type'] == type
  }
  collections.flatten!
  return datas unless collections.count > 0
  collections.each do |d|
    next unless d['description']
    datas << {
      name: d['type'] != 'line' ? I18n.t("report.default_view.#{d['type']}") : d['description'],
      type: d['type'],
      status: d['status']&.downcase&.to_sym,
      count_error: d['check_point_error_count'].to_i,
      count_warning: d['check_point_warning_count'].to_i,
      check_point_errors: d['check_point_errors']
    }.tap{ |hash|
      hash[:error_or_warning] = (hash[:count_error] + hash[:count_warning]) > 0
    }
  end
  return sort_datas(datas)
  # search_for(datas)
end

#filesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/services/ievkit_views/action_report.rb', line 19

def files
  datas = []
  return datas unless @report['files']
  @report['files'].each do |d|
    next unless d['name']
    datas << {
      name: d['name'],
      type: d['type'],
      status: d['status']&.downcase&.to_sym,
      count_error: d['check_point_error_count'].to_i,
      count_warning: d['check_point_warning_count'].to_i,
      check_point_errors: d['check_point_errors']
    }.tap{ |hash|
      hash[:error_or_warning] = (hash[:count_error] + hash[:count_warning]) > 0
    }
  end
  return sort_datas(datas)
  #search_for(datas)
end

#objects(type = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/services/ievkit_views/action_report.rb', line 39

def objects(type = nil)
  datas = []
  return datas unless @report['objects']
  @report['objects'].each do |d|
    next unless d['type']
    next if type && type != d['type']
    datas << {
      name: d['type'] != 'line' ? I18n.t("report.default_view.#{d['type']}") : d['description'],
      type: d['type'],
      status: d['status']&.downcase&.to_sym,
      count_error: d['check_point_error_count'].to_i,
      count_warning: d['check_point_warning_count'].to_i,
      check_point_errors: d['check_point_errors']
    }.tap{ |hash|
      hash[:error_or_warning] = (hash[:count_error] + hash[:count_warning]) > 0
    }
  end
  return sort_datas(datas)
  # search_for(datas)
end

#progressionObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/ievkit_views/action_report.rb', line 4

def progression
  progression = @report['progression']
  return {} unless progression
  index_current_step = progression['current_step'].to_i - 1
  @datas = {
    current_step: progression['current_step'].to_i,
    steps_count: progression['steps_count'].to_i,
    current_step_realized: progression['steps'][index_current_step]['realized'].to_i,
    current_step_total: progression['steps'][index_current_step]['total'].to_i
  }.tap{ |hash|
    hash[:steps_percent] = hash[:current_step].percent_of(hash[:steps_count]).round(2)
    hash[:current_step_percent] = hash[:current_step_realized].percent_of(hash[:current_step_total]).round(2)
  }
end