@@ -19,10 +19,7 @@ def show
1919 private
2020
2121 def find_job
22- # GoodJob stores jobs in the good_jobs table as Executions
23- # The job_id returned to users is the ActiveJob ID
24- # We need to query by active_job_id, not by execution id
25- job = GoodJob ::Execution . find_by ( active_job_id : params [ :id ] )
22+ job = GoodJob ::Job . find_by ( active_job_id : params [ :id ] )
2623
2724 # Verify this is an import job (security check)
2825 return nil unless job && job . job_class == SchoolImportJob . name
@@ -40,7 +37,7 @@ def build_job_response(job)
4037 }
4138
4239 # If job is finished successfully, get results from dedicated table
43- if job . finished_at . present? && job . error . blank ?
40+ if job . succeeded ?
4441 result = SchoolImportResult . find_by ( job_id : job . active_job_id )
4542 if result
4643 response [ :results ] = result . results
@@ -49,20 +46,21 @@ def build_job_response(job)
4946 end
5047 end
5148
52- # Include error if job failed
49+ # Include error if job failed or was discarded
5350 if job . error . present?
5451 response [ :error ] = job . error
55- response [ :status ] = 'failed'
52+ response [ :status ] = job . discarded? ? 'discarded' : 'failed'
5653 end
5754
5855 response
5956 end
6057
6158 def job_status ( job )
62- return 'failed' if job . error . present?
63- return 'completed' if job . finished_at . present?
59+ return 'discarded' if job . discarded?
60+ return 'succeeded' if job . succeeded?
61+ return 'failed' if job . finished? && job . error . present?
62+ return 'running' if job . running?
6463 return 'scheduled' if job . scheduled_at . present? && job . scheduled_at > Time . current
65- return 'running' if job . performed_at . present? && job . finished_at . nil?
6664
6765 'queued'
6866 end
0 commit comments