From 456090043283002d978e655f23192b7c4a240c20 Mon Sep 17 00:00:00 2001 From: Vibol Teav Date: Wed, 23 Aug 2023 23:01:06 +0700 Subject: [PATCH 1/3] allow more retry on sidekqi --- config/initializers/sidekiq.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 8919117733..202c2e2248 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,5 +1,5 @@ Sidekiq::Extensions.enable_delay! -Sidekiq.default_worker_options = { retry: 3, backtrace: true } +Sidekiq.default_worker_options = { backtrace: true } Sidekiq.configure_server do |config| config.redis = { url: (ENV["REDIS_URL"] || 'redis://localhost:6379/0') } From c31af854ef5014118f31db7a9c974d0cbc40e14e Mon Sep 17 00:00:00 2001 From: Vibol Teav Date: Wed, 23 Aug 2023 23:10:52 +0700 Subject: [PATCH 2/3] fix seeding data --- app/models/organization.rb | 3 +++ db/seeds.rb | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/organization.rb b/app/models/organization.rb index 910acbc2bc..cc8da05e5e 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -96,6 +96,9 @@ def seed_generic_data(org_id, referral_source_category_name=nil) Importer::Import.new('Quantitative Case', general_data_file).quantitative_cases Rake::Task["field_settings:import"].invoke(org.short_name) Rake::Task["field_settings:import"].reenable + + Thredded::MessageboardGroup.find_or_create_by(name: 'Archived', position: 0) + referral_source_category = ReferralSource.find_by(name_en: referral_source_category_name) if referral_source_category referral_source = ReferralSource.find_or_create_by(name: "#{org.full_name} - OSCaR Referral") diff --git a/db/seeds.rb b/db/seeds.rb index 9f6380c852..6f928408c1 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1822,8 +1822,6 @@ Location.find_or_create_by(name: 'ផ្សេងៗ Other', order_option: 1) -Thredded::MessageboardGroup.find_or_create_by(name: 'Archived', position: 0) - # Organization.create_and_build_tenant(short_name: 'ngo_subdomain', full_name: 'NGO Name', logo: File.open(Rails.root.join('path_to_ngo_logo'))) interviewees = ['កុមារ', 'ឪពុកម្ដាយ', 'អ្នកអាណាព្យាបាល', 'អ្នកថែទាំ', 'ផ្សេងៗ (សូមបញ្ជាក់)'] From 262337a61222b375a93c645e105184692a34eb76 Mon Sep 17 00:00:00 2001 From: Vibol Teav Date: Wed, 23 Aug 2023 23:28:58 +0700 Subject: [PATCH 3/3] add rake task to clean unused schema --- lib/tasks/clean_unused_schema.rake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/tasks/clean_unused_schema.rake diff --git a/lib/tasks/clean_unused_schema.rake b/lib/tasks/clean_unused_schema.rake new file mode 100644 index 0000000000..d55873d05f --- /dev/null +++ b/lib/tasks/clean_unused_schema.rake @@ -0,0 +1,15 @@ +desc 'Clean unused schema' +task :clean_unused_schema => :environment do + Organization.without_shared.only_deleted.each do |org| + puts "================ Dropping schema #{org.short_name} ================" + + begin + Apartment::Tenant.drop(org.short_name) + rescue Apartment::TenantNotFound => e + puts "================ Schema #{org.short_name} not found ================" + end + + UsageReport.where(organization_id: org.id).destroy_all + org.destroy_fully! + end +end