DEV: Use Rails autoloading (#321)
This commit enables Rails autoloading for Data Explorer. See: https://meta.discourse.org/t/structuring-a-plugin-for-rails-autoloading/256092
This commit is contained in:
parent
d31d89942e
commit
e23c31195b
|
@ -4,5 +4,8 @@ module ::DiscourseDataExplorer
|
|||
class Engine < ::Rails::Engine
|
||||
engine_name PLUGIN_NAME
|
||||
isolate_namespace DiscourseDataExplorer
|
||||
config.autoload_paths << File.join(config.root, "lib")
|
||||
scheduled_job_dir = "#{config.root}/app/jobs/scheduled"
|
||||
config.to_prepare { Rails.autoloaders.main.eager_load_dir(scheduled_job_dir) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,12 +32,6 @@ end
|
|||
require_relative "lib/discourse_data_explorer/engine"
|
||||
|
||||
after_initialize do
|
||||
require_relative "app/jobs/scheduled/delete_hidden_queries"
|
||||
require_relative "lib/discourse_data_explorer/data_explorer"
|
||||
require_relative "lib/discourse_data_explorer/parameter"
|
||||
require_relative "lib/discourse_data_explorer/queries"
|
||||
require_relative "lib/discourse_data_explorer/query_group_bookmarkable"
|
||||
|
||||
GlobalSetting.add_default(:max_data_explorer_api_reqs_per_10_seconds, 2)
|
||||
|
||||
# Available options:
|
||||
|
@ -77,9 +71,6 @@ after_initialize do
|
|||
{ run_queries: { actions: %w[discourse_data_explorer/query#run], params: %i[id] } },
|
||||
)
|
||||
|
||||
require_relative "lib/report_generator"
|
||||
require_relative "lib/result_to_markdown"
|
||||
require_relative "lib/result_format_converter"
|
||||
reloadable_patch do
|
||||
if defined?(DiscourseAutomation)
|
||||
add_automation_scriptable("recurring_data_explorer_result_pm") do
|
||||
|
|
Loading…
Reference in New Issue