Merge pull request #235 from openHPI/remove_old_hints

Completely remove old hints connected to the execution environment
This commit is contained in:
rteusner
2018-11-30 15:41:01 +01:00
committed by GitHub
41 changed files with 54 additions and 744 deletions

View File

@ -1,45 +0,0 @@
module CodeOcean
class ErrorsController < ApplicationController
before_action :set_execution_environment
def authorize!
authorize(@error || @errors)
end
private :authorize!
def create
@error = CodeOcean::Error.new(error_params)
authorize!
hint = Whistleblower.new(execution_environment: @error.execution_environment).generate_hint(@error.message)
respond_to do |format|
format.json do
if hint
render(json: {hint: hint})
else
head (@error.save ? :created : :unprocessable_entity)
end
end
end
end
def error_params
params[:error].permit(:message, :submission_id).merge(execution_environment_id: @execution_environment.id) if params[:error].present?
end
private :error_params
def index
@errors = CodeOcean::Error.for_execution_environment(@execution_environment).grouped_by_message.paginate(page: params[:page])
authorize!
end
def set_execution_environment
@execution_environment = ExecutionEnvironment.find(params[:execution_environment_id])
end
private :set_execution_environment
def show
@error = CodeOcean::Error.find(params[:id])
authorize!
end
end
end

View File

@ -1,57 +0,0 @@
class HintsController < ApplicationController
include CommonBehavior
before_action :set_execution_environment
before_action :set_hint, only: MEMBER_ACTIONS
def authorize!
authorize(@hint || @hints)
end
private :authorize!
def create
@hint = Hint.new(hint_params)
authorize!
create_and_respond(object: @hint, path: proc { execution_environment_hint_path(@execution_environment, @hint) })
end
def destroy
destroy_and_respond(object: @hint, path: execution_environment_hints_path(@execution_environment))
end
def edit
end
def hint_params
params[:hint].permit(:locale, :message, :name, :regular_expression).merge(execution_environment_id: @execution_environment.id) if params[:hint].present?
end
private :hint_params
def index
@hints = @execution_environment.hints.order(:name).paginate(page: params[:page])
authorize!
end
def new
@hint = Hint.new
authorize!
end
def set_execution_environment
@execution_environment = ExecutionEnvironment.find(params[:execution_environment_id])
end
private :set_execution_environment
def set_hint
@hint = Hint.find(params[:id])
authorize!
end
private :set_hint
def show
end
def update
update_and_respond(object: @hint, params: hint_params, path: execution_environment_hint_path(@execution_environment, @hint))
end
end

View File

@ -126,14 +126,6 @@ class SubmissionsController < ApplicationController
# server_sent_event.write({stdout: output[:stdout]}, event: 'output') if output[:stdout]
# server_sent_event.write({stderr: output[:stderr]}, event: 'output') if output[:stderr]
# unless output[:stderr].nil?
# if hint = Whistleblower.new(execution_environment: @submission.execution_environment).generate_hint(output[:stderr])
# server_sent_event.write(hint, event: 'hint')
# else
# store_error(output[:stderr])
# end
# end
# end
hijack do |tubesock|
@ -365,11 +357,6 @@ class SubmissionsController < ApplicationController
head :ok
end
def store_error(stderr)
CodeOcean::Error.create(submission_id: @submission.id, execution_environment_id: @submission.execution_environment.id, message: stderr)
end
private :store_error
def test
hijack do |tubesock|
Thread.new { EventMachine.run } unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?