Skip to content

Commit 0be1fc6

Browse files
committed
Mail scramble files along with main results file
1 parent 0ccc5c1 commit 0be1fc6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/mailers/competitions_mailer.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,23 @@ def results_submitted(competition, results_validator, message, submitter_user)
150150
@message = message
151151
@submitter_user = submitter_user
152152
last_uploaded_json = @competition.uploaded_jsons.order(:id).last
153-
if last_uploaded_json
153+
if last_uploaded_json.present?
154154
attachments["Results for #{@competition.id}.json"] = {
155155
mime_type: "application/json",
156156
content: last_uploaded_json.json_str,
157157
}
158+
# If the upload type is the classic "Results JSON", then *everything* is contained
159+
# within the file that was uploaded by the Delegate, including scrambles.
160+
# If the WCA Live sync was used, it means that scrambles were uploaded separately,
161+
# so we have to add them as attachments for record keeping.
162+
if last_uploaded_json.wca_live?
163+
@competition.scramble_file_uploads.each do |scr_file_upload|
164+
attachments[scr_file_upload.original_filename] = {
165+
mime_type: "application/json",
166+
content: scr_file_upload.raw_wcif.to_json,
167+
}
168+
end
169+
end
158170
end
159171
mail(
160172
from: "results@worldcubeassociation.org",

0 commit comments

Comments
 (0)