Skip to content

Commit d29e5ed

Browse files
committed
be aggressive with saves
1 parent c4c44ea commit d29e5ed

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

app/controllers/basil_controller.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,11 @@ def commission
551551

552552
def complete_commission
553553
commission = BasilCommission.find_by(job_id: params[:jobid])
554-
return if commission.nil?
555-
556-
commission.update(completed_at: DateTime.current,
557-
final_settings: JSON.parse(params[:settings]))
554+
raise "Tried to complete commission with invalid job ID #{params[:jobid]}" if commission.nil?
555+
556+
merged_settings = commission.final_settings || {}
557+
commission.update!(completed_at: DateTime.current,
558+
final_settings: merged_settings.merge(JSON.parse(params.fetch(:settings, "{}"))))
558559

559560
# Attach the image in S3 to our `image` ActiveStorage relation
560561
key = "job-#{params[:jobid]}.png"

app/models/basil_commission.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def submit_to_job_queue!
1818

1919
# TODO clean this up and put it in a service
2020
sts_client = Aws::STS::Client.new(region: region)
21-
queue_url = 'https://sqs.' + region + '.amazonaws.com/' +
22-
sts_client.get_caller_identity.account + '/' + queue_name
21+
queue_url = 'https://sqs.' + region + '.amazonaws.com/' + sts_client.get_caller_identity.account + '/' + queue_name
2322
sqs_client = Aws::SQS::Client.new(region: region)
2423

2524
message_body = {

app/views/basil/jam.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@
293293
<%= commission.prompt %>
294294
</blockquote>
295295
</li>
296+
<li>
297+
<small><%= commission.job_id %></small>
298+
</li>
296299
</ul>
297300
</div>
298301
</div>

0 commit comments

Comments
 (0)