From ef6c785acad0bb1eb59ca3310847f717d8c24d63 Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Thu, 23 Feb 2023 14:09:52 -0300 Subject: [PATCH] DEV: Move jobs undear each module lib directory --- lib/modules/nsfw/entry_point.rb | 2 +- .../modules/nsfw/jobs/regular}/evaluate_content.rb | 0 lib/modules/sentiment/entry_point.rb | 2 +- .../sentiment/jobs/regular}/sentiment_classify_post.rb | 0 lib/modules/toxicity/entry_point.rb | 6 ++---- .../jobs/regular}/toxicity_classify_chat_message.rb | 0 .../toxicity/jobs/regular}/toxicity_classify_post.rb | 0 .../modules/nsfw/jobs/regular}/evaluate_content_spec.rb | 2 +- spec/support/nsfw_inference_stubs.rb | 1 + 9 files changed, 6 insertions(+), 7 deletions(-) rename {app/jobs/regular/modules/nsfw => lib/modules/nsfw/jobs/regular}/evaluate_content.rb (100%) rename {app/jobs/regular/modules/sentiment => lib/modules/sentiment/jobs/regular}/sentiment_classify_post.rb (100%) rename {app/jobs/regular/modules/toxicity => lib/modules/toxicity/jobs/regular}/toxicity_classify_chat_message.rb (100%) rename {app/jobs/regular/modules/toxicity => lib/modules/toxicity/jobs/regular}/toxicity_classify_post.rb (100%) rename spec/{jobs/regular/modules/nsfw => lib/modules/nsfw/jobs/regular}/evaluate_content_spec.rb (91%) diff --git a/lib/modules/nsfw/entry_point.rb b/lib/modules/nsfw/entry_point.rb index 25f3614e..a0eeb280 100644 --- a/lib/modules/nsfw/entry_point.rb +++ b/lib/modules/nsfw/entry_point.rb @@ -5,7 +5,7 @@ module DiscourseAI class EntryPoint def inject_into(plugin) require_relative "evaluation.rb" - require_relative "../../../app/jobs/regular/modules/nsfw/evaluate_content.rb" + require_relative "jobs/regular/evaluate_content.rb" plugin.add_model_callback(Upload, :after_create) do Jobs.enqueue(:evaluate_content, upload_id: self.id) diff --git a/app/jobs/regular/modules/nsfw/evaluate_content.rb b/lib/modules/nsfw/jobs/regular/evaluate_content.rb similarity index 100% rename from app/jobs/regular/modules/nsfw/evaluate_content.rb rename to lib/modules/nsfw/jobs/regular/evaluate_content.rb diff --git a/lib/modules/sentiment/entry_point.rb b/lib/modules/sentiment/entry_point.rb index de9c5f83..c0a31464 100644 --- a/lib/modules/sentiment/entry_point.rb +++ b/lib/modules/sentiment/entry_point.rb @@ -5,7 +5,7 @@ module DiscourseAI def inject_into(plugin) require_relative "event_handler.rb" require_relative "post_classifier.rb" - require_relative "../../../app/jobs/regular/modules/sentiment/sentiment_classify_post.rb" + require_relative "jobs/regular/sentiment_classify_post.rb" plugin.on(:post_created) do |post| DiscourseAI::Sentiment::EventHandler.handle_post_async(post) diff --git a/app/jobs/regular/modules/sentiment/sentiment_classify_post.rb b/lib/modules/sentiment/jobs/regular/sentiment_classify_post.rb similarity index 100% rename from app/jobs/regular/modules/sentiment/sentiment_classify_post.rb rename to lib/modules/sentiment/jobs/regular/sentiment_classify_post.rb diff --git a/lib/modules/toxicity/entry_point.rb b/lib/modules/toxicity/entry_point.rb index 4eecc25c..12a172ac 100644 --- a/lib/modules/toxicity/entry_point.rb +++ b/lib/modules/toxicity/entry_point.rb @@ -8,10 +8,8 @@ module DiscourseAI require_relative "post_classifier.rb" require_relative "chat_message_classifier.rb" - jobs_base_path = "../../../app/jobs/regular/modules/toxicity" - - require_relative "#{jobs_base_path}/toxicity_classify_post.rb" - require_relative "#{jobs_base_path}/toxicity_classify_chat_message.rb" + require_relative "jobs/regular/toxicity_classify_post.rb" + require_relative "jobs/regular/toxicity_classify_chat_message.rb" plugin.on(:post_created) do |post| DiscourseAI::Toxicity::EventHandler.handle_post_async(post) diff --git a/app/jobs/regular/modules/toxicity/toxicity_classify_chat_message.rb b/lib/modules/toxicity/jobs/regular/toxicity_classify_chat_message.rb similarity index 100% rename from app/jobs/regular/modules/toxicity/toxicity_classify_chat_message.rb rename to lib/modules/toxicity/jobs/regular/toxicity_classify_chat_message.rb diff --git a/app/jobs/regular/modules/toxicity/toxicity_classify_post.rb b/lib/modules/toxicity/jobs/regular/toxicity_classify_post.rb similarity index 100% rename from app/jobs/regular/modules/toxicity/toxicity_classify_post.rb rename to lib/modules/toxicity/jobs/regular/toxicity_classify_post.rb diff --git a/spec/jobs/regular/modules/nsfw/evaluate_content_spec.rb b/spec/lib/modules/nsfw/jobs/regular/evaluate_content_spec.rb similarity index 91% rename from spec/jobs/regular/modules/nsfw/evaluate_content_spec.rb rename to spec/lib/modules/nsfw/jobs/regular/evaluate_content_spec.rb index 929d2cb0..c74c0a68 100644 --- a/spec/jobs/regular/modules/nsfw/evaluate_content_spec.rb +++ b/spec/lib/modules/nsfw/jobs/regular/evaluate_content_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "rails_helper" -require_relative "../../../../support/nsfw_inference_stubs" +require_relative "../../../../../support/nsfw_inference_stubs" describe Jobs::EvaluateContent do fab!(:image) { Fabricate(:s3_image_upload) } diff --git a/spec/support/nsfw_inference_stubs.rb b/spec/support/nsfw_inference_stubs.rb index a5009793..08730f57 100644 --- a/spec/support/nsfw_inference_stubs.rb +++ b/spec/support/nsfw_inference_stubs.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class NSFWInferenceStubs class << self def endpoint