Add experimental machine learning

This commit is contained in:
Machine Learning
2021-06-18 12:27:29 +07:00
committed by Javi Martín
parent c8d8fae98d
commit 4d27bbebad
84 changed files with 2845 additions and 30 deletions

View File

@@ -0,0 +1,33 @@
class Admin::MachineLearningController < Admin::BaseController
before_action :load_machine_learning_job, only: [:show, :execute]
def show
end
def execute
@machine_learning_job.update!(script: params[:script],
user: current_user,
started_at: Time.current,
finished_at: nil,
error: nil)
::MachineLearning.new(@machine_learning_job).run
redirect_to admin_machine_learning_path,
notice: t("admin.machine_learning.script_info", email: current_user.email)
end
def cancel
Delayed::Job.where(queue: "machine_learning").destroy_all
MachineLearningJob.destroy_all
redirect_to admin_machine_learning_path,
notice: t("admin.machine_learning.notice.delete_generated_content")
end
private
def load_machine_learning_job
@machine_learning_job = MachineLearningJob.first_or_initialize
end
end