diff options
| author | Zakaria BOUZIANE | 2015-04-30 09:39:26 +0200 |
|---|---|---|
| committer | Zakaria BOUZIANE | 2015-04-30 09:39:26 +0200 |
| commit | 9b785f79e34cff001a5eeed2d3118ca26f82aa4e (patch) | |
| tree | e276ed5ad06eabaf27250512d7c7f0ec5c86671f /app/models | |
| parent | 854fb22f32028b283bef0b3a76a6ca0e67f130de (diff) | |
| download | chouette-core-9b785f79e34cff001a5eeed2d3118ca26f82aa4e.tar.bz2 | |
Showing ComplianceCheck RuleParameterSet
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/compliance_check.rb | 52 | ||||
| -rw-r--r-- | app/models/compliance_check_report.rb | 5 | ||||
| -rw-r--r-- | app/models/compliance_check_task.rb | 18 | ||||
| -rw-r--r-- | app/models/rule_parameter_set.rb | 2 |
4 files changed, 20 insertions, 57 deletions
diff --git a/app/models/compliance_check.rb b/app/models/compliance_check.rb index cc201037f..a2b2a7f52 100644 --- a/app/models/compliance_check.rb +++ b/app/models/compliance_check.rb @@ -16,8 +16,18 @@ class ComplianceCheck end end end + + def report + report_path = links["action_report"] + if report_path + response = Ievkit.get(report_path) + ComplianceCheckReport.new(response) + else + raise Ievkit::IevError("Impossible to access report path link for compliance check") + end + end - def compliance_check_result + def compliance_check_validation_report report_path = links["validation_report"] if report_path response = Ievkit.get(report_path) @@ -55,23 +65,7 @@ class ComplianceCheck end def status - # pending processing completed failed - # CREATED, SCHEDULED, STARTED, TERMINATED, CANCELED, ABORTED, DELETED - if datas.status == "CREATED" - "pending" - elsif datas.status == "SCHEDULED" - "pending" - elsif datas.status == "STARTED" - "processing" - elsif datas.status == "TERMINATED" - "completed" - elsif datas.status == "CANCELED" - "failed" - elsif datas.status == "ABORTED" - "failed" - elsif datas.status == "DELETED" - "failed" - end + datas.status.downcase end def format @@ -94,30 +88,12 @@ class ComplianceCheck datas.action_parameters.user_name end - def created_at? - datas.created? - end - def created_at - Time.at(datas.created.to_i / 1000) if created_at? - end - - def updated_at? - datas.updated? + Time.at(datas.created.to_i / 1000) if datas.created end def updated_at - Time.at(datas.updated.to_i / 1000) if updated_at? - end - - def percentage_progress - if %w{created}.include? status - 0 - elsif %w{ terminated canceled aborted }.include? status - 100 - else - 20 - end + Time.at(datas.updated.to_i / 1000) if datas.updated end end diff --git a/app/models/compliance_check_report.rb b/app/models/compliance_check_report.rb new file mode 100644 index 000000000..2c2da6452 --- /dev/null +++ b/app/models/compliance_check_report.rb @@ -0,0 +1,5 @@ +class ComplianceCheckReport + include ReportConcern + +end + diff --git a/app/models/compliance_check_task.rb b/app/models/compliance_check_task.rb index 7a344066f..5d9ce6ca2 100644 --- a/app/models/compliance_check_task.rb +++ b/app/models/compliance_check_task.rb @@ -97,24 +97,6 @@ class ComplianceCheckTask datas.type end - # def filename - # datas.links.select{ |link| link["rel"] == "data"}.first.href.gsub( /\/.*\//, "" ) - # end - - # def filename_extension - # File.extname(filename) if filename - # end - - def percentage_progress - if %w{created}.include? status - 0 - elsif %w{ terminated canceled aborted }.include? status - 100 - else - 20 - end - end - def referential_id Referential.where(:slug => referential_name).id end diff --git a/app/models/rule_parameter_set.rb b/app/models/rule_parameter_set.rb index 1901383c5..cd5a5d976 100644 --- a/app/models/rule_parameter_set.rb +++ b/app/models/rule_parameter_set.rb @@ -321,7 +321,7 @@ class RuleParameterSet < ActiveRecord::Base end def allowed(mode) - return true unless self.check_allowed_transport_modes + return true unless self.check_allowed_transport_modes == "1" # puts "#{mode} = "+self.send("allowed_transport_mode_#{mode}").to_s return self.send("allowed_transport_mode_#{mode}") == "1" end |
