mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
* Add reset with sample data option on profile settings * No need for "member" user in preload * Cleanup/shorten copy
24 lines
685 B
Ruby
24 lines
685 B
Ruby
class FamilyResetJob < ApplicationJob
|
|
queue_as :low_priority
|
|
|
|
def perform(family, load_sample_data_for_email: nil)
|
|
# Delete all family data except users
|
|
ActiveRecord::Base.transaction do
|
|
# Delete accounts and related data
|
|
family.accounts.destroy_all
|
|
family.categories.destroy_all
|
|
family.tags.destroy_all
|
|
family.merchants.destroy_all
|
|
family.plaid_items.destroy_all
|
|
family.imports.destroy_all
|
|
family.budgets.destroy_all
|
|
end
|
|
|
|
if load_sample_data_for_email.present?
|
|
Demo::Generator.new.generate_new_user_data_for!(family.reload, email: load_sample_data_for_email)
|
|
else
|
|
family.sync_later
|
|
end
|
|
end
|
|
end
|