Fix faulty API data format

This commit is contained in:
Konrad Hanff
2021-04-01 13:18:29 +02:00
committed by Sebastian Serth
parent 28f8de1a93
commit c36ec447ff
2 changed files with 3 additions and 3 deletions

View File

@ -21,14 +21,14 @@ class Container
def copy_files(files) def copy_files(files)
url = container_url + "/files" url = container_url + "/files"
body = files.map{ |filename, content| { filename => content } } body = { files: files.map{ |filename, content| { filename: filename, content: content } } }
Faraday.post(url, body.to_json, HEADERS) Faraday.post(url, body.to_json, HEADERS)
end end
def copy_submission_files(submission) def copy_submission_files(submission)
files = {} files = {}
submission.collect_files.each do |file| submission.collect_files.each do |file|
files[file.name] = file.content files[file.name_with_extension] = file.content
end end
copy_files(files) copy_files(files)
end end

View File

@ -4,7 +4,7 @@ class ContainerConnection
EVENTS = %i[start output exit stdout stderr].freeze EVENTS = %i[start output exit stdout stderr].freeze
def initialize(url) def initialize(url)
@socket = Faye::WebSocket::Client.new(url, [], ping: 0.1) @socket = Faye::WebSocket::Client.new(url, [], ping: 5)
%i[open message error close].each do |event_type| %i[open message error close].each do |event_type|
@socket.on event_type do |event| __send__(:"on_#{event_type}", event) end @socket.on event_type do |event| __send__(:"on_#{event_type}", event) end