Fix some non-autocorrectable linting issues

Many functions in submission_controller.rb still are very long and have
a high complexity. Because the logic for handling execution of
submissions will probably move elsewhere (when switching to
ActionCable), this is fine for now.
This commit is contained in:
Konrad Hanff
2021-04-07 14:43:34 +02:00
committed by Sebastian Serth
parent 80932c0c40
commit 575057acd3
3 changed files with 48 additions and 55 deletions

View File

@ -50,8 +50,7 @@ class Runner
end
def status
# parse(Faraday.get(runner_url))[:status].to_sym
# TODO return actual state retrieved via websocket
# TODO: return actual state retrieved via websocket
:timeouted
end

View File

@ -43,20 +43,7 @@ class RunnerConnection
return unless BACKEND_OUTPUT_SCHEMA.valid?(JSON.parse(event.data))
event = decode(event.data)
# TODO: handle other events like timeout
case event[:type].to_sym
when :exit_code
@exit_code = event[:data]
when :stderr
@stderr_callback.call event[:data]
@output_callback.call event[:data]
when :stdout
@stdout_callback.call event[:data]
@output_callback.call event[:data]
else
:error
end
__send__("handle_#{event[:type]}", event)
end
def on_open(_event)
@ -68,4 +55,26 @@ class RunnerConnection
def on_close(_event)
@exit_callback.call @exit_code
end
def handle_exit(event)
@exit_code = event[:data]
end
def handle_stdout(event)
@stdout_callback.call event[:data]
@output_callback.call event[:data]
end
def handle_stderr(event)
@stderr_callback.call event[:data]
@output_callback.call event[:data]
end
def handle_error(event) end
def handle_start(event) end
def handle_timeout(event)
# TODO: set the runner state
end
end