From 7f456069d9be6606d003af46e8db0bb0b0aec0d1 Mon Sep 17 00:00:00 2001 From: Jennifer Byrne Date: Fri, 20 Oct 2023 12:33:38 -0500 Subject: [PATCH] make updates to ease testing on staging --- app/controllers/public_channel_controller.rb | 2 +- app/models/channel.rb | 4 ++-- .../database_updates/backfill_channel_public_identifiers.rake | 4 ++-- test/fixtures/channels.yml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/public_channel_controller.rb b/app/controllers/public_channel_controller.rb index a5e4b58220..5a3d0372f3 100644 --- a/app/controllers/public_channel_controller.rb +++ b/app/controllers/public_channel_controller.rb @@ -14,7 +14,7 @@ def show } # Handle the case when the resource is not found - if channel.nil? || @crypto_addresses.empty? || current_publisher != channel.publisher || !current_publisher.feature_flags["p2p_enabled"] + if channel.nil? || @crypto_addresses.empty? || !current_publisher.feature_flags["p2p_enabled"] redirect_to root_path, alert: "Channel not found" end end diff --git a/app/models/channel.rb b/app/models/channel.rb index 5e18b7dd52..01c01b13d7 100644 --- a/app/models/channel.rb +++ b/app/models/channel.rb @@ -363,9 +363,9 @@ def has_valid_uphold_connection? end def set_public_identifier - return if public_identifier.present? + # return if public_identifier.present? identifier = loop do - id = SecureRandom.hex(10) + id = SecureRandom.alphanumeric(10) break id unless Channel.where(public_identifier: id).exists? end diff --git a/lib/tasks/database_updates/backfill_channel_public_identifiers.rake b/lib/tasks/database_updates/backfill_channel_public_identifiers.rake index 9d3150f63e..926373b249 100644 --- a/lib/tasks/database_updates/backfill_channel_public_identifiers.rake +++ b/lib/tasks/database_updates/backfill_channel_public_identifiers.rake @@ -1,8 +1,8 @@ namespace :database_updates do desc "Backfill Channel public_identifiers" task backfill_channel_public_identifiers: :environment do - puts "Attempting to update #{Channel.where(public_identifier: nil).count} channels" - Channel.where(public_identifier: nil).pluck(:id).each_slice(1000) do |channel_chunk| + puts "Attempting to update #{Channel.all.count} channels" + Channel.all.pluck(:id).each_slice(1000) do |channel_chunk| CreatePublicIdentifiersJob.perform_later(channel_chunk) end puts "Done!" diff --git a/test/fixtures/channels.yml b/test/fixtures/channels.yml index 6640349a03..6aa6788307 100644 --- a/test/fixtures/channels.yml +++ b/test/fixtures/channels.yml @@ -159,13 +159,13 @@ alice_default_twitter: publisher: default details: uphold_connected_twitter_default (TwitterChannelDetails) verified: true - public_identifier: 'c6587d7de522444595e2' + public_identifier: 'S8baxMJnPl' alice_default_twitter_ii: publisher: default details: uphold_connected_twitter_default_ii (TwitterChannelDetails) verified: true - public_identifier: 'fd04faddd96bdd3b9840' + public_identifier: 'aOxAg8BAJe' youtube_initial: publisher: youtube_initial