lib/cloud_crowd/models/job.rb in documentcloud-cloud-crowd-0.0.5 vs lib/cloud_crowd/models/job.rb in documentcloud-cloud-crowd-0.0.6
- old
+ new
@@ -20,11 +20,11 @@
def self.create_from_request(h)
self.create(
:inputs => h['inputs'].to_json,
:action => h['action'],
:options => (h['options'] || {}).to_json,
- :owner_email => h['owner_email'],
+ :email => h['email'],
:callback_url => h['callback_url']
)
end
# After work units are marked successful, we check to see if all of them have
@@ -95,15 +95,10 @@
klass = CloudCrowd.actions[self.action]
return klass if klass
raise ActionNotFound, "no action named: '#{self.action}' could be found"
end
- # Get the displayable status name of the Job's status code.
- def display_status
- CloudCrowd.display_status(self.status)
- end
-
# How complete is this Job?
def percent_complete
return 0 if splitting?
return 100 if complete?
return 99 if merging?
@@ -123,17 +118,18 @@
# A JSON representation of this job includes the statuses of its component
# WorkUnits, as well as any completed outputs.
def to_json(opts={})
atts = {
- 'id' => self.id,
- 'color' => self.color,
- 'status' => self.display_status,
- 'percent_complete' => self.percent_complete,
- 'work_units' => self.work_units.count,
- 'time_taken' => self.time_taken
+ 'id' => id,
+ 'color' => color,
+ 'status' => display_status,
+ 'percent_complete' => percent_complete,
+ 'work_units' => work_units.count,
+ 'time_taken' => time_taken
}
- atts.merge!({'outputs' => JSON.parse(self.outputs)}) if self.outputs
+ atts['outputs'] = JSON.parse(outputs) if outputs
+ atts['email'] = email if email
atts.to_json
end
private
\ No newline at end of file