Class: CloudhdrJob
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- CloudhdrJob
- Defined in:
- app/models/cloudhdr_job.rb
Class Method Summary collapse
- .update_from_cloudhdr(params) ⇒ Object
- .update_from_cloudhdr_generic_job(params) ⇒ Object
- .update_from_cloudhdr_generic_job_with_thumbnails(params) ⇒ Object
- .update_from_cloudhdr_job_style(params) ⇒ Object
- .update_from_cloudhdr_thumbnail_job(params) ⇒ Object
- .update_image_and_job_from_img_params(image, job, img_params) ⇒ Object
- .update_pending_jobs ⇒ Object
Instance Method Summary collapse
-
#initialize(params = {}, options = {}) ⇒ CloudhdrJob
constructor
scope :for_components, :conditions => “tracking_mode = ‘component’” scope :for_jobs, :conditions => “tracking_mode = ‘job’”.
- #update_status ⇒ Object
Constructor Details
#initialize(params = {}, options = {}) ⇒ CloudhdrJob
scope :for_components, :conditions => “tracking_mode = ‘component’” scope :for_jobs, :conditions => “tracking_mode = ‘job’”
9 10 11 12 |
# File 'app/models/cloudhdr_job.rb', line 9 def initialize(params = {}, ={}) super #self.tracking_mode = "component" unless self.tracking_mode end |
Class Method Details
.update_from_cloudhdr(params) ⇒ Object
75 76 77 78 79 80 81 |
# File 'app/models/cloudhdr_job.rb', line 75 def self.update_from_cloudhdr(params) #if params.keys.include?("inputs") && params.keys.include?("outputs") update_from_cloudhdr_job_style(params) #else # update_from_cloudhdr_component_style(params) #end end |
.update_from_cloudhdr_generic_job(params) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'app/models/cloudhdr_job.rb', line 119 def self.update_from_cloudhdr_generic_job(params) #debugger job = self.find_by_cloudhdr_job_id params[:job][:id] image = job.image img_params = params[:outputs].first update_image_and_job_from_img_params(image,job,img_params) image.cloudhdr_status = "ready" if image.respond_to?(:cloudhdr_status=) image.cloudhdr_status = "ready" if image.respond_to?(:cloudhdr_status=) image.save! image.fire_ready_callback job.cloudhdr_status = "ready" job.save job end |
.update_from_cloudhdr_generic_job_with_thumbnails(params) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'app/models/cloudhdr_job.rb', line 137 def self.update_from_cloudhdr_generic_job_with_thumbnails(params) #debugger job = self.find_by_cloudhdr_job_id params[:job][:id] image = job.image img_params = {} params[:outputs].each do |thumb_params| if thumb_params[:label].blank? img_params = thumb_params next end thumbnail = image.thumbnail_for(thumb_params[:label]) update_image_and_job_from_img_params(thumbnail,job,thumb_params) thumbnail.cloudhdr_status = "ready" if thumbnail.respond_to?(:cloudhdr_status=) thumbnail.cloudhdr_status = "ready" if thumbnail.respond_to?(:cloudhdr_status=) thumbnail.save! end update_image_and_job_from_img_params(image,job,img_params) image.cloudhdr_status = "ready" if image.respond_to?(:cloudhdr_status=) image.cloudhdr_status = "ready" if image.respond_to?(:cloudhdr_status=) image.save! image.fire_ready_callback job.cloudhdr_status = "ready" job.save job end |
.update_from_cloudhdr_job_style(params) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'app/models/cloudhdr_job.rb', line 83 def self.update_from_cloudhdr_job_style(params) if params[:job][:type] == 'ThumbnailJob' update_from_cloudhdr_thumbnail_job(params) elsif params[:job][:type] == 'CompositeJob' || params[:job][:type] == 'ToneMappingJob' update_from_cloudhdr_generic_job_with_thumbnails(params) else update_from_cloudhdr_generic_job(params) end end |
.update_from_cloudhdr_thumbnail_job(params) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'app/models/cloudhdr_job.rb', line 93 def self.update_from_cloudhdr_thumbnail_job(params) #debugger job = self.find_by_cloudhdr_job_id params[:job][:id] image = job.image img_params = params[:inputs].first update_image_and_job_from_img_params(image,job,img_params) params[:outputs].each do |thumb_params| thumbnail = image.thumbnail_for(thumb_params[:label]) update_image_and_job_from_img_params(thumbnail,job,thumb_params) thumbnail.cloudhdr_status = "ready" if thumbnail.respond_to?(:cloudhdr_status=) thumbnail.cloudhdr_status = "ready" if thumbnail.respond_to?(:cloudhdr_status=) thumbnail.save! end image.cloudhdr_status = "ready" if image.respond_to?(:cloudhdr_status=) image.cloudhdr_status = "ready" if image.respond_to?(:cloudhdr_status=) image.save! image.fire_ready_callback job.cloudhdr_status = "ready" job.save job end |
.update_image_and_job_from_img_params(image, job, img_params) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'app/models/cloudhdr_job.rb', line 171 def self.update_image_and_job_from_img_params(image,job,img_params) [ :file_size,:width,:height,:taken_at,:lat,:lng,:saturated_pixels,:gauss,:bits_per_pixel,:camera_make, :camera_model, :orientation, :exposure_time, :f_number, :iso_speed_rating, :exposure_bias_value, :focal_length, :focal_length_in_35mm_film, :subsec_time, :pixels, :processing_time].each do |att| setter = att.to_s + "=" if image.respond_to? setter and !img_params[att].blank? image.send setter, img_params[att] end if job.respond_to? setter and !img_params[att].blank? job.send setter, img_params[att] end end end |
.update_pending_jobs ⇒ Object
68 69 70 71 72 |
# File 'app/models/cloudhdr_job.rb', line 68 def self.update_pending_jobs CloudhdrJob.pending.find_each do |e| e.update_status end end |
Instance Method Details
#update_status ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/models/cloudhdr_job.rb', line 14 def update_status job_data = Cloudhdr::Job.details(cloudhdr_job_id).body #puts job_data.to_json puts " CloudhdrJob #{id} = #{job_data["aasm_state"]}" puts "job_data = #{job_data}" puts "*" * 50 puts "cloudhdr_input_id = #{cloudhdr_input_id}" if cloudhdr_input_id job_data["inputs"].each do |input| #puts "input = #{input.to_json}" puts "input id = #{input["id"]} my cloudhdr_input_id = #{cloudhdr_input_id}" if input["id"] == cloudhdr_input_id input.symbolize_keys! params = { :class => image_type, :id => image_id, :job => { :id => job_data["id"] }, :input => input } CloudhdrJob.update_from_cloudhdr(params) end end elsif cloudhdr_output_id outputs = (job_data["thumbnails"] || []) + (job_data["hdrs"] || []) + (job_data["tone_mappings"] || []) + (job_data["composites"] || []) + (job_data["hdr_htmls"] || []) outputs.each do |output| if output["id"] == cloudhdr_output_id output.symbolize_keys! output[:url] = output[:base_url] + output[:filename] params = { :class => image_type, :id => image_id, :job => { :id => job_data["id"] }, :output => output } CloudhdrJob.update_from_cloudhdr(params) end end end puts "+++++++++++++++" #if job_data["aasm_state"] == "complete" # self.cloudhdr_status = "ready" # self.image.cloudhdr_status = "ready" # self.image.thumbnails.each do |t| # t.cloudhdr_status = "ready" # end # self.save # #self.image.save #end end |