From e66764fcfc499aea02bcc1d271cb60b2bdc2c637 Mon Sep 17 00:00:00 2001 From: drusepth Date: Wed, 2 Mar 2022 23:39:59 -0800 Subject: [PATCH 01/14] remove tds --- app/services/technical_debt_service.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/services/technical_debt_service.rb diff --git a/app/services/technical_debt_service.rb b/app/services/technical_debt_service.rb deleted file mode 100644 index e69de29b..00000000 From c4f0ce692fed6a1f564bb65bee38f89e2cc4d301 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 10 Mar 2022 12:44:19 -0800 Subject: [PATCH 02/14] Add premium storage space to prepaid activations (#1099) --- app/jobs/pay_pal_prepay_processing_job.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/jobs/pay_pal_prepay_processing_job.rb b/app/jobs/pay_pal_prepay_processing_job.rb index 3ca107af..cf88cd75 100644 --- a/app/jobs/pay_pal_prepay_processing_job.rb +++ b/app/jobs/pay_pal_prepay_processing_job.rb @@ -27,6 +27,13 @@ class PayPalPrepayProcessingJob < ApplicationJob unless invoice.status == 'COMPLETED' invoice.update(status: 'COMPLETED') invoice.generate_promo_code! + + # Add the extra Premium space + SubscriptionService.add_any_referral_bonuses(invoice.user, 'premium') + + # Rather than queueing up a job to run N months from now to reset space, + # we'll probably go with a worker that ensures everyone's space is correct + # every day. Worker TBD. end else From 33495e55ac8db9c765273fc0198b1ab60c3d4e6e Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 10 Mar 2022 12:51:57 -0800 Subject: [PATCH 03/14] queue a downgrade job several months in the future to reset prepay storage, needs testing --- app/jobs/pay_pal_prepay_processing_job.rb | 5 +---- app/jobs/premium_downgrade_job.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 app/jobs/premium_downgrade_job.rb diff --git a/app/jobs/pay_pal_prepay_processing_job.rb b/app/jobs/pay_pal_prepay_processing_job.rb index cf88cd75..5b025b37 100644 --- a/app/jobs/pay_pal_prepay_processing_job.rb +++ b/app/jobs/pay_pal_prepay_processing_job.rb @@ -30,10 +30,7 @@ class PayPalPrepayProcessingJob < ApplicationJob # Add the extra Premium space SubscriptionService.add_any_referral_bonuses(invoice.user, 'premium') - - # Rather than queueing up a job to run N months from now to reset space, - # we'll probably go with a worker that ensures everyone's space is correct - # every day. Worker TBD. + PremiumDowngradeJob.set(wait: (invoice.months).months).perform_later(invoice.user_id) end else diff --git a/app/jobs/premium_downgrade_job.rb b/app/jobs/premium_downgrade_job.rb new file mode 100644 index 00000000..c4ad07e2 --- /dev/null +++ b/app/jobs/premium_downgrade_job.rb @@ -0,0 +1,15 @@ +class PremiumDowngradeJob < ApplicationJob + queue_as :low_priority + + def perform(*args) + user_id = args.shift + + user = User.find_by(id: user_id) + raise "No user to downgrade; id=#{user_id}" if user.nil? + + # Remove any bonus bandwidth granted by the plan + premium_bandwidth_bonus = BillingPlan.find(4).bonus_bandwidth_kb + user.update!(upload_bandwidth_kb: user.upload_bandwidth_kb - premium_bandwidth_bonus) + end + +end \ No newline at end of file From 9232720a525ff9220960e4fe64e2331728a23102 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 10 Mar 2022 14:39:07 -0800 Subject: [PATCH 04/14] end creature promo --- app/models/page_types/creature.rb | 2 +- config/initializers/promos.rb | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/app/models/page_types/creature.rb b/app/models/page_types/creature.rb index 19ad5da3..61925486 100644 --- a/app/models/page_types/creature.rb +++ b/app/models/page_types/creature.rb @@ -20,7 +20,7 @@ class Creature < ApplicationRecord include Serendipitous::Concern include Authority::Abilities - self.authorizer_name = 'CoreContentAuthorizer' + self.authorizer_name = 'ExtendedContentAuthorizer' # Locations relates :habitats, with: :wildlifeships diff --git a/config/initializers/promos.rb b/config/initializers/promos.rb index 560d1547..b1b5cb9b 100644 --- a/config/initializers/promos.rb +++ b/config/initializers/promos.rb @@ -14,12 +14,3 @@ if Date.current >= 'March 1, 2020'.to_date Rails.application.config.content_types[:premium] -= [Lore] end end - -# Lore free during the month of October -# Need to change Creature.rb authorizer at the end -if Date.current >= 'October 1, 2021'.to_date - if Date.current < 'November 1, 2021'.to_date - Rails.application.config.content_types[:free] << Creature - Rails.application.config.content_types[:premium] -= [Creature] - end -end From 0375e46a08791ff3877d266f96655537365bf172 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 10 Mar 2022 14:41:10 -0800 Subject: [PATCH 05/14] add data integrity task for upload bandwidths --- lib/tasks/data_integrity.rake | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/tasks/data_integrity.rake b/lib/tasks/data_integrity.rake index 0f738259..bc59c93f 100644 --- a/lib/tasks/data_integrity.rake +++ b/lib/tasks/data_integrity.rake @@ -111,5 +111,23 @@ namespace :data_integrity do end end + + desc "Ensure all users have the correct upload bandwidth amounts" + task correct_bandwidths: :environment do + base_bandwidth = User.new.upload_bandwidth_kb # 50_000 + premium_bonus = BillingPlan.find(4).bonus_bandwidth_kb # 9_950_000 + premium_total = base_bandwidth + premium_bonus # 10_000_000 + + User.find_each do |user| + max_bandwidth = BillingPlan::PREMIUM_IDS.include?(user.selected_billing_plan_id) ? premium_total : base_bandwidth + used_bandwidth = user.image_uploads.sum(:src_file_size) + + remaining_bandwidth = max_bandwidth - used_bandwidth + if user.upload_bandwidth_kb != remaining_bandwidth + puts "Correcting user #{user.id} bandwidth: #{user.upload_bandwidth_kb} --> #{remaining_bandwidth}" + # user.update(upload_bandwidth_kb: remaining_bandwidth) + end + end + end end From bdd0c4769593353c8907c6d4ea8dc2778b934175 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 10 Mar 2022 15:05:01 -0800 Subject: [PATCH 06/14] incorporate referral bonuses in integrity task --- lib/tasks/data_integrity.rake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/tasks/data_integrity.rake b/lib/tasks/data_integrity.rake index bc59c93f..0ee75b4f 100644 --- a/lib/tasks/data_integrity.rake +++ b/lib/tasks/data_integrity.rake @@ -117,17 +117,26 @@ namespace :data_integrity do base_bandwidth = User.new.upload_bandwidth_kb # 50_000 premium_bonus = BillingPlan.find(4).bonus_bandwidth_kb # 9_950_000 premium_total = base_bandwidth + premium_bonus # 10_000_000 + referral_bonus = 100_000 # per referral + + puts "Disabling SQL logging" + old_logger = ActiveRecord::Base.logger + ActiveRecord::Base.logger = nil User.find_each do |user| max_bandwidth = BillingPlan::PREMIUM_IDS.include?(user.selected_billing_plan_id) ? premium_total : base_bandwidth + referral_bonus = user.referrals.count * referral_bonus used_bandwidth = user.image_uploads.sum(:src_file_size) - remaining_bandwidth = max_bandwidth - used_bandwidth + remaining_bandwidth = max_bandwidth + referral_bonus - used_bandwidth if user.upload_bandwidth_kb != remaining_bandwidth puts "Correcting user #{user.id} bandwidth: #{user.upload_bandwidth_kb} --> #{remaining_bandwidth}" # user.update(upload_bandwidth_kb: remaining_bandwidth) end end + + puts "Re-enabling SQL logging" + ActiveRecord::Base.logger = old_logger end end From 81ff2b6436c774d85096828b1318b43e66a1a5af Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 10 Mar 2022 15:14:54 -0800 Subject: [PATCH 07/14] debugging --- lib/tasks/data_integrity.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/data_integrity.rake b/lib/tasks/data_integrity.rake index 0ee75b4f..22aba9ab 100644 --- a/lib/tasks/data_integrity.rake +++ b/lib/tasks/data_integrity.rake @@ -130,7 +130,7 @@ namespace :data_integrity do remaining_bandwidth = max_bandwidth + referral_bonus - used_bandwidth if user.upload_bandwidth_kb != remaining_bandwidth - puts "Correcting user #{user.id} bandwidth: #{user.upload_bandwidth_kb} --> #{remaining_bandwidth}" + puts "Correcting user #{user.id} bandwidth: #{user.upload_bandwidth_kb} --> #{remaining_bandwidth} (#{used_bandwidth} used)" # user.update(upload_bandwidth_kb: remaining_bandwidth) end end From a82f7f6c9766ec2d5a119217ed50e8ff2714b8fa Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 10 Mar 2022 15:54:38 -0800 Subject: [PATCH 08/14] handle free-for-lifers --- lib/tasks/data_integrity.rake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/tasks/data_integrity.rake b/lib/tasks/data_integrity.rake index 22aba9ab..448a8dda 100644 --- a/lib/tasks/data_integrity.rake +++ b/lib/tasks/data_integrity.rake @@ -124,7 +124,17 @@ namespace :data_integrity do ActiveRecord::Base.logger = nil User.find_each do |user| - max_bandwidth = BillingPlan::PREMIUM_IDS.include?(user.selected_billing_plan_id) ? premium_total : base_bandwidth + max_bandwidth = case user.selected_billing_plan_id + when 1 + base_bandwidth + when 2 # free-for-lifers + 250_000 + when 4, 5, 6 # premium + premium_total + else + raise "User with funky billing plan id: U=#{user.id} BP=#{user.selected_billing_plan_id}" + end + referral_bonus = user.referrals.count * referral_bonus used_bandwidth = user.image_uploads.sum(:src_file_size) From d694381be3e2594e9b39c9db4fdb5cfd3e1d5f03 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 10 Mar 2022 16:42:52 -0800 Subject: [PATCH 09/14] no bp = starter --- lib/tasks/data_integrity.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/data_integrity.rake b/lib/tasks/data_integrity.rake index 448a8dda..fc555478 100644 --- a/lib/tasks/data_integrity.rake +++ b/lib/tasks/data_integrity.rake @@ -125,7 +125,7 @@ namespace :data_integrity do User.find_each do |user| max_bandwidth = case user.selected_billing_plan_id - when 1 + when nil, 1 base_bandwidth when 2 # free-for-lifers 250_000 From 9c0ca611f8609e733558b887a882febade988249 Mon Sep 17 00:00:00 2001 From: drusepth Date: Sun, 20 Mar 2022 16:07:49 -0700 Subject: [PATCH 10/14] add a default Description field on all new language templates --- config/attributes/language.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/attributes/language.yml b/config/attributes/language.yml index 0db82303..f4b9d605 100644 --- a/config/attributes/language.yml +++ b/config/attributes/language.yml @@ -7,6 +7,8 @@ :field_type: name - :name: other_names :label: Other names + - :name: description + :label: Description - :name: universe_id :label: Universe :field_type: universe From 89cb8ce9192b02fd42885d14d84af9585c63d669 Mon Sep 17 00:00:00 2001 From: drusepth Date: Sun, 20 Mar 2022 16:45:01 -0700 Subject: [PATCH 11/14] use description field as language byline --- app/models/page_types/language.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/page_types/language.rb b/app/models/page_types/language.rb index c2e94f6e..0ff155b0 100644 --- a/app/models/page_types/language.rb +++ b/app/models/page_types/language.rb @@ -16,8 +16,7 @@ class Language < ApplicationRecord self.authorizer_name = 'ExtendedContentAuthorizer' def description - num_speakers = Lingualism.where(spoken_language_id: id).count - "Language spoken by #{ActionController::Base.helpers.pluralize num_speakers, 'character'}" + overview_field_value('Description') end def self.color From 505d85dd77045eebb66c7cd3f336b6cec43b10d9 Mon Sep 17 00:00:00 2001 From: drusepth Date: Sun, 20 Mar 2022 16:58:03 -0700 Subject: [PATCH 12/14] unguard integrity rake task --- lib/tasks/data_integrity.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/data_integrity.rake b/lib/tasks/data_integrity.rake index fc555478..77a6bd2e 100644 --- a/lib/tasks/data_integrity.rake +++ b/lib/tasks/data_integrity.rake @@ -141,7 +141,7 @@ namespace :data_integrity do remaining_bandwidth = max_bandwidth + referral_bonus - used_bandwidth if user.upload_bandwidth_kb != remaining_bandwidth puts "Correcting user #{user.id} bandwidth: #{user.upload_bandwidth_kb} --> #{remaining_bandwidth} (#{used_bandwidth} used)" - # user.update(upload_bandwidth_kb: remaining_bandwidth) + user.update(upload_bandwidth_kb: remaining_bandwidth) end end From 8a461ee65af21ce778e5fb5e3ab6d2b71eca9e9a Mon Sep 17 00:00:00 2001 From: drusepth Date: Sun, 20 Mar 2022 19:47:38 -0700 Subject: [PATCH 13/14] rain replacement --- app/services/forum_replacement_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/forum_replacement_service.rb b/app/services/forum_replacement_service.rb index 7d0576f9..139941d6 100644 --- a/app/services/forum_replacement_service.rb +++ b/app/services/forum_replacement_service.rb @@ -243,7 +243,7 @@ class ForumReplacementService < Service 'prison' => 'hoosegow locker', 'raccoon' => 'trash burgler', 'radio' => 'magic musicbox', - 'rain' => 'cloudy waterdrops', + 'rain' => 'cloudy juice', 'recursion' => 'recursion', 'replaced' => 'improved', 'reverse' => 'esrever', From 292f136aa34c136549ff31c8a9df2975e2bb7fdf Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 21 Mar 2022 00:10:26 -0700 Subject: [PATCH 14/14] remove old test --- test/controllers/page_tags_controller_test.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/controllers/page_tags_controller_test.rb b/test/controllers/page_tags_controller_test.rb index 2f89a08a..a3f2da9f 100644 --- a/test/controllers/page_tags_controller_test.rb +++ b/test/controllers/page_tags_controller_test.rb @@ -1,9 +1,5 @@ require 'test_helper' class PageTagsControllerTest < ActionDispatch::IntegrationTest - test "should get remove" do - get page_tags_remove_url - assert_response :success - end end