Skip to content

Commit

Permalink
fix: update save status on actions
Browse files Browse the repository at this point in the history
  • Loading branch information
macite committed Aug 25, 2023
1 parent 37afa4e commit e04609e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
4 changes: 4 additions & 0 deletions app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ def extensions_must_end_with_due_date
end
end

def description
"#{task_definition.abbreviation} for #{project.student.username}"
end

def all_comments
if group_submission.nil?
comments
Expand Down
41 changes: 23 additions & 18 deletions app/models/turn_it_in/tii_action_upload_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def update_from_pdf_report_status(response)
when 'SUCCESS' # Similarity report is complete
entity.status = :similarity_pdf_requested
entity.save
save_and_reset_retry
save_progress
download_similarity_report_pdf(skip_check: true)
# else # pending or unknown...
end
Expand All @@ -41,13 +41,12 @@ def update_from_submission_status(response)
when 'COMPLETE' # Submission processing is complete
entity.status = :submission_complete
entity.save
save_and_reset_retry
save_and_reschedule # Request the similarity report

request_similarity_report
when 'ERROR' # An error occurred during submission processing; see error_code for details
save_and_log_custom_error response.error_code
Doubtfire::Application.config.logger.error "Error with tii submission: #{id} #{self.custom_error_message}"
save_and_reset_retry
end
end

Expand Down Expand Up @@ -78,16 +77,17 @@ def update_from_similarity_status(response)
similarity.save
end

# Reset for new request
save_and_reset_retry

# Request the PDF if flagged
request_similarity_report_pdf if flag
# If we need to get the pdf report... request it
if flag
save_and_reschedule
# Request the PDF if flagged
request_similarity_report_pdf
else
save_and_mark_complete
end
end
end

private

# Run is designed to be run in a background job, polling in
# case of the need to retry actions. This will ensure submissions progress
# through turn it in when web hooks fails.
Expand Down Expand Up @@ -150,7 +150,7 @@ def fetch_tii_submission_id
entity.status = :has_id
entity.save

save_and_reset_retry
save_and_reschedule

# If we had to indicate the eula was accepted, then we need to update the user
unless submitted_by_user.tii_eula_version_confirmed
Expand Down Expand Up @@ -337,7 +337,7 @@ def request_similarity_report_pdf
entity.similarity_pdf_id = result.id
entity.save

save_and_reset_retry
save_and_reschedule
end
end

Expand All @@ -363,16 +363,21 @@ def download_similarity_report_pdf(skip_check: false)
)

filename = similarity_pdf_path
file = File.new(filename, 'wb')
begin
file.write(result)
ensure
file.close

if result.instance_of? Tempfile
FileUtils.mv(result.path, filename)
else
file = File.new(filename, 'wb')
begin
file.write(result)
ensure
file.close
end
end

entity.status = :similarity_pdf_downloaded
entity.save
save_and_reset_retry
save_and_mark_complete

true
end
Expand Down
10 changes: 4 additions & 6 deletions app/models/turn_it_in/tii_action_upload_task_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ def update_from_attachment_status(response)
entity.status = :complete
entity.save

self.complete = true
save_and_reset_retry
save_and_mark_complete
when 'ERROR'
self.error_code = :custom_tii_error
self.custom_error_message = response.error_code
Doubtfire::Application.config.logger.error "Error with tii submission: #{id} #{self.custom_error_message}"
save_and_reset_retry
save_and_log_custom_error
end
end

Expand Down Expand Up @@ -78,7 +77,7 @@ def fetch_tii_group_attachment_id
entity.status = :has_id
entity.save

save_and_reset_retry
save_and_reschedule
end
end

Expand All @@ -101,8 +100,7 @@ def upload_attachment_to_tii
)

entity.update(status: :uploaded)

save_and_reset_retry
save_and_reschedule
end
end

Expand Down

0 comments on commit e04609e

Please sign in to comment.