aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/export.rb
diff options
context:
space:
mode:
authorLuc Donnet2015-05-07 14:15:18 +0200
committerLuc Donnet2015-05-07 14:15:18 +0200
commit46c9cd634a1b2f36df872bd0acbca25884673810 (patch)
treeb71c7b3b3e0781b691dd13c87f20df3de0c4a26e /app/models/export.rb
parented6fd2af69ebecb8d6af496135f1398ef6332b06 (diff)
downloadchouette-core-46c9cd634a1b2f36df872bd0acbca25884673810.tar.bz2
Fix export
Diffstat (limited to 'app/models/export.rb')
-rw-r--r--app/models/export.rb62
1 files changed, 10 insertions, 52 deletions
diff --git a/app/models/export.rb b/app/models/export.rb
index 22475af0b..ee008d590 100644
--- a/app/models/export.rb
+++ b/app/models/export.rb
@@ -1,30 +1,15 @@
class Export
- extend Enumerize
- extend ActiveModel::Naming
- extend ActiveModel::Translation
- include ActiveModel::Model
+ include JobConcern
- attr_reader :datas
-
- def initialize(response)
- @datas = response
- end
-
- def links
- {}.tap do |links|
- datas.links.each do |link|
- links[link["rel"]] = link["href"]
- end
- end
- end
-
def report
- report_path = links["action_report"]
- if report_path
- response = Ievkit.get(report_path)
- ExportReport.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)
+ ExportReport.new(response)
+ else
+ nil
+ end
end
end
@@ -51,37 +36,10 @@ class Export
def filename_extension
File.extname(filename).gsub(".", "") if filename
- end
-
- def id
- datas.id
- end
-
- def status
- datas.status.downcase
- end
+ end
def format
datas.format
end
-
- def referential_name
- datas.referential
- end
-
- def name
- datas.action_parameters.name
- end
- def user_name
- datas.action_parameters.user_name
- end
-
- def created_at
- Time.at(datas.created.to_i / 1000) if datas.created
- end
-
- def updated_at
- Time.at(datas.updated.to_i / 1000) if datas.updated
- end
end