Skip to content

Commit

Permalink
DEV: Use Rails autoloading (#321)
Browse files Browse the repository at this point in the history
This commit enables Rails autoloading for Data Explorer. See:

https://meta.discourse.org/t/structuring-a-plugin-for-rails-autoloading/256092
  • Loading branch information
Lhcfl authored Aug 28, 2024
1 parent d31d899 commit e23c311
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lib/discourse_data_explorer/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ module ::DiscourseDataExplorer
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:
Expand Down Expand Up @@ -77,9 +71,6 @@ module ::DiscourseDataExplorer
{ 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
Expand Down

0 comments on commit e23c311

Please sign in to comment.