Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 and removes unneeded promo code code
  • Loading branch information
tsmartt committed Jun 7, 2024
1 parent e8a706a commit 05d9cf3
Show file tree
Hide file tree
Showing 16 changed files with 2 additions and 443 deletions.
1 change: 0 additions & 1 deletion app/controllers/admin/publishers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def show

def wallet_info
@publisher = Publisher.find(params[:publisher_id])
@referral_owner_status = PromoClient.owner_state.find(id: @publisher.id)
render partial: "wallet_info"
end

Expand Down
10 changes: 0 additions & 10 deletions app/controllers/publishers/promo_registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ def index
end
end

def create
return unless Rails.env.development? || Rails.env.test?
@publisher = current_publisher
current_publisher.channels.find_each do |channel|
channel.register_channel_for_promo # Callee does a check
end
@promo_enabled_channels = @publisher.channels.joins(:promo_registration)
@publisher_has_verified_channel = @publisher.has_verified_channel?
end

def for_referral_code
promo_registration = user.promo_registrations.find_by(referral_code: params[:referral_code])

Expand Down
13 changes: 0 additions & 13 deletions app/jobs/promo/register_channel_for_promo_job.rb

This file was deleted.

22 changes: 0 additions & 22 deletions app/jobs/promo/update_status.rb

This file was deleted.

13 changes: 0 additions & 13 deletions app/models/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class Channel < ApplicationRecord
# *ChannelDetails get autosaved from above.
after_save :update_site_banner_lookup!, if: -> { saved_change_to_verified && verified? }

after_commit :register_channel_for_promo, if: :should_register_channel_for_promo?
after_commit :create_channel_card, if: -> { saved_change_to_verified? && verified? }

before_save :clear_verified_at_if_necessary
Expand Down Expand Up @@ -334,10 +333,6 @@ def gemini_connection
@gemini_connection ||= gemini_connection_for_channel.first
end

def register_channel_for_promo
Promo::RegisterChannelForPromoJob.perform_now(id, 0)
end

def update_site_banner_lookup!(skip_site_banner_info_lookup: false)
return unless verified?
site_banner_lookup = SiteBannerLookup.find_or_initialize_by(
Expand Down Expand Up @@ -379,14 +374,6 @@ def set_public_identifier!

private

def should_register_channel_for_promo?
publisher.may_create_referrals? &&
publisher.may_register_promo? &&
saved_change_to_verified? &&
verified &&
!publisher.only_user_funds?
end

def clear_verified_at_if_necessary
self.verified_at = nil if verified == false && verified_at.present?
end
Expand Down
24 changes: 0 additions & 24 deletions app/models/concerns/referral_promo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,4 @@ def promo_lockout_time_passed?
return promo_lockout_time < DateTime.now if promo_lockout_time.present?
false
end

# Public: Validates if the user's country is on the excluded list.
#
# Returns true or false depending on if the country is included.
def valid_promo_country?
PromoRegistration::RESTRICTED_COUNTRIES.exclude?(country)
end

def may_register_promo?
# If the user doesn't have the referral_kyc_flag on then we can register them still.
return true unless referral_kyc_required?

# Otherwise they must be brave payable and from a valid country
brave_payable? && valid_promo_country?
end

# Public: Enqueues a job which allows publishers referrals to work if they are payable and in a valid promo_country
#
# Returns nil
def update_promo_status!
return unless may_register_promo?

Promo::UpdateStatus.perform_later(id, PublisherStatusUpdate::ACTIVE)
end
end
10 changes: 0 additions & 10 deletions app/models/publisher_status_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,8 @@ class PublisherStatusUpdate < ApplicationRecord

validates :publisher_id, presence: true

# After a user creates a new status then we should check to see the previous staus and call backing server
after_create :update_services, if: :should_update?

after_create :make_previously_suspended_channels

# Queues a job to call the promo server to update the owner state for the publisher based on the status
#
# @return [nil]
def update_services
Promo::UpdateStatus.perform_later(publisher_id, status)
end

def should_update?
valid_transitions = [ACTIVE, SUSPENDED, ONLY_USER_FUNDS]
previous_status = publisher.status_updates.second&.status
Expand Down
8 changes: 0 additions & 8 deletions app/models/uphold_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class UpholdAccountState
################

after_save :update_site_banner_lookup!, if: -> { saved_change_to_attribute(:is_member) }
after_save :update_promo_status, if: -> { saved_change_to_attribute(:is_member) }
after_commit :create_uphold_cards, on: :create

#################
Expand Down Expand Up @@ -290,13 +289,6 @@ def update_site_banner_lookup!
publisher.update_site_banner_lookup!
end

# Internal: If the publisher previously had referral codes and then we will re-activate their referral codes.
#
# Returns nil
def update_promo_status
publisher.update_promo_status!
end

def japanese_account?
country == JAPAN
end
Expand Down
140 changes: 0 additions & 140 deletions app/services/promo/assign_promo_to_channel_service.rb

This file was deleted.

4 changes: 0 additions & 4 deletions app/services/promo/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ def initialize(connection = nil, options = {})
@connection = connection
end

def owner_state
@owner_state ||= Promo::Models::OwnerState.new(connection)
end

def reporting
@reporting ||= Promo::Models::Reporting.new(connection)
end
Expand Down
8 changes: 0 additions & 8 deletions app/views/admin/publishers/_wallet_info.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@
.db-info-row
.db-field = "Referral confirmations:"
.db-value = publisher_referral_totals(@publisher)[PromoRegistration::FINALIZED]
.db-info-row
.db-field
= "Referral owner status"
span data-tooltip="If the user is 'no-ugp' this means their promos will 404"
= fa_icon 'question-circle', class: 'mx-1'
= ": "

.db-value= @referral_owner_status

#statement-section.split-row
.payout-report-status-section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Admin::Publishers::PublisherStatusUpdatesControllerTest < ActionDispatch::
sign_in admin
publisher = publishers(:uphold_connected)

assert_enqueued_jobs(2) do
assert_enqueued_jobs(1) do
post(
admin_publisher_publisher_status_updates_path(
publisher_id: publisher.id,
Expand All @@ -69,7 +69,7 @@ class Admin::Publishers::PublisherStatusUpdatesControllerTest < ActionDispatch::
admin = publishers(:admin)
sign_in admin
publisher = publishers(:uphold_connected)
assert_enqueued_jobs(1) do
assert_enqueued_jobs(0) do
post(
admin_publisher_publisher_status_updates_path(
publisher_id: publisher.id,
Expand Down
18 changes: 0 additions & 18 deletions test/controllers/channels_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,6 @@ class ChannelsControllerTest < ActionDispatch::IntegrationTest
end
end

test "delete removes a channel even if promo is enabled" do
publisher = publishers(:small_media_group)
channel = channels(:global_verified)
sign_in publisher

post promo_registrations_path

Promo::RegisterChannelForPromoJob.perform_now(publisher.channels.first.id)
assert_not_nil publisher.channels.first.promo_registration.referral_code

assert_difference("publisher.channels.count", 0) do
assert_difference("SiteChannelDetails.count", 0) do
delete channel_path(channel), headers: {"HTTP_ACCEPT" => "application/json"}
assert_response 404
end
end
end

test "cancel_add removes an unverified channel and redirects to the dashboard" do
publisher = publishers(:default)
channel = channels(:new_site)
Expand Down
13 changes: 0 additions & 13 deletions test/jobs/delete_publisher_channel_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ class DeletePublisherChannelJobTest < ActionDispatch::IntegrationTest
end
end

test "does not throw error if channel has a promo_regsitration" do
publisher = publishers(:completed)
sign_in publisher

# enable the promo
post promo_registrations_path
Promo::RegisterChannelForPromoJob.perform_now(publisher.channels.first.id)
assert_not_nil publisher.channels.first.promo_registration.referral_code
assert_nothing_raised do
DeletePublisherChannelJob.perform_now(publisher.channels.first.id)
end
end

test "deletes unverifed channel" do
channel = channels(:default)
DeletePublisherChannelJob.perform_now(channel.id)
Expand Down
Loading

0 comments on commit 05d9cf3

Please sign in to comment.