Skip to content

Commit

Permalink
Ensure tasks are loaded
Browse files Browse the repository at this point in the history
If the task isn't loaded this method errors with
Don't know how to build task 'dfe:analytics:import_entity'
This change ensures the rake tasks are loaded
  • Loading branch information
rjlynch committed Nov 12, 2024
1 parent f62de1f commit d98e9fc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/analytics_importer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
class AnalyticsImporter
ANALYTICS_SYNC_TASK = "dfe:analytics:import_entity"

def self.import(model)
Rake::Task["dfe:analytics:import_entity"].invoke(model.table_name) if DfE::Analytics.enabled?
return unless DfE::Analytics.enabled?

if Rake::Task.tasks.map(&:name).exclude?(ANALYTICS_SYNC_TASK)
Rails.application.load_tasks
end

Rake::Task[ANALYTICS_SYNC_TASK].invoke(model.table_name)
end
end

0 comments on commit d98e9fc

Please sign in to comment.