aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2015-05-07 16:40:18 +0200
committerLuc Donnet2015-05-07 16:40:18 +0200
commitb1a1422a2f203f1b31d799719fc11cdd608695a4 (patch)
tree42769296cd4afe40bb15ac4da2ccfd1dea4cd1fb
parentd6f9c8d86f1f2c7f482a700d446b7a1a63c8e29d (diff)
downloadchouette-core-b1a1422a2f203f1b31d799719fc11cdd608695a4.tar.bz2
Add cache for import
-rw-r--r--app/models/import.rb52
1 files changed, 30 insertions, 22 deletions
diff --git a/app/models/import.rb b/app/models/import.rb
index 54795361e..be469d282 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -4,40 +4,48 @@ class Import
include JobConcern
def compliance_check_validation_report
- report_path = links["validation_report"]
- if report_path
- response = Ievkit.get(report_path)
- ComplianceCheckResult.new(response)
- else
- raise Ievkit::IevError("Impossible to access report path link for validation of import")
+ Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do
+ report_path = links["validation_report"]
+ if report_path
+ response = Ievkit.get(report_path)
+ ComplianceCheckResult.new(response)
+ else
+ raise Ievkit::IevError("Impossible to access report path link for validation of import")
+ end
end
end
def report
- report_path = links["action_report"]
- if report_path
- response = Ievkit.get(report_path)
- ImportReport.new(response)
- else
- nil
+ Rails.cache.fetch("#{cache_key}/action_report", expires_in: cache_expiration) do
+ report_path = links["action_report"]
+ if report_path
+ response = Ievkit.get(report_path)
+ ImportReport.new(response)
+ else
+ nil
+ end
end
end
def rule_parameter_set
- rule_parameter_set_path = links["validation_params"]
- if rule_parameter_set_path
- ::JSON.load( open(rule_parameter_set_path).read )
- else
- nil
+ Rails.cache.fetch("#{cache_key}/validation_params", expires_in: cache_expiration) do
+ rule_parameter_set_path = links["validation_params"]
+ if rule_parameter_set_path
+ ::JSON.load( open(rule_parameter_set_path).read )
+ else
+ nil
+ end
end
end
def compliance_check
- compliance_check_path = links["validation_report"]
- if compliance_check_path
- ::JSON.load( open(compliance_check_path).read )
- else
- nil
+ Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do
+ compliance_check_path = links["validation_report"]
+ if compliance_check_path
+ ::JSON.load( open(compliance_check_path).read )
+ else
+ nil
+ end
end
end