From 5e9ee7f8fde6b80803985c2b0ab4502b4a2270e2 Mon Sep 17 00:00:00 2001 From: Min Khant Kyaw Date: Mon, 28 Jul 2025 22:24:35 +0630 Subject: [PATCH 1/7] Merge branch 'exclude_not_recommended' --- config/application.rb | 4 +-- config/initializers/bullet.rb | 28 +++++++++---------- config/initializers/rack_profiler.rb | 20 +++++++------- lib/middleware/bullet_logger.rb | 40 ++++++++++++++-------------- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/config/application.rb b/config/application.rb index 07276ddc..78ee0c3d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -6,8 +6,8 @@ require 'doorkeeper' -# require_relative '../lib/middleware/bullet_logger' -# require_relative '../lib/middleware/query_profiler' +require_relative '../lib/middleware/bullet_logger' +require_relative '../lib/middleware/query_profiler' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. diff --git a/config/initializers/bullet.rb b/config/initializers/bullet.rb index 8e4e143e..39b44f3f 100644 --- a/config/initializers/bullet.rb +++ b/config/initializers/bullet.rb @@ -1,15 +1,15 @@ -# if Rails.env.development? || Rails.env.local? -# require 'stringio' -# require 'logger' -# Bullet.enable = true -# Bullet.alert = true -# Bullet.bullet_logger = true -# Bullet.console = true -# Bullet.rails_logger = true -# Bullet.add_footer = false # Disable HTML injection for APIs +if Rails.env.development? || Rails.env.local? + require 'stringio' + require 'logger' + Bullet.enable = true + Bullet.alert = true + Bullet.bullet_logger = true + Bullet.console = true + Bullet.rails_logger = true + Bullet.add_footer = false # Disable HTML injection for APIs -# # For Postman/N+1 detection in logs: -# ActiveSupport::Notifications.subscribe('n_plus_one_query') do |event| -# Rails.logger.warn "N+1 Query detected: #{event.payload[:message]}" -# end -# end \ No newline at end of file + # For Postman/N+1 detection in logs: + ActiveSupport::Notifications.subscribe('n_plus_one_query') do |event| + Rails.logger.warn "N+1 Query detected: #{event.payload[:message]}" + end +end \ No newline at end of file diff --git a/config/initializers/rack_profiler.rb b/config/initializers/rack_profiler.rb index 5485c3fe..ccdf4841 100644 --- a/config/initializers/rack_profiler.rb +++ b/config/initializers/rack_profiler.rb @@ -1,13 +1,13 @@ -return unless Rails.env.development? +if Rails.env.development? + begin + require 'rack-mini-profiler' -begin - require 'rack-mini-profiler' + # Start the profiler + ::Rack::MiniProfilerRails.initialize!(Rails.application) - # Start the profiler - ::Rack::MiniProfilerRails.initialize!(Rails.application) - - # Optional: Customize settings - Rack::MiniProfiler.config.position = 'bottom' # display at bottom of page -rescue LoadError => e - Rails.logger.warn "rack-mini-profiler not available: #{e.message}" + # Optional: Customize settings + Rack::MiniProfiler.config.position = 'bottom' # display at bottom of page + rescue LoadError => e + Rails.logger.warn "rack-mini-profiler not available: #{e.message}" + end end \ No newline at end of file diff --git a/lib/middleware/bullet_logger.rb b/lib/middleware/bullet_logger.rb index 12082255..23f43a90 100644 --- a/lib/middleware/bullet_logger.rb +++ b/lib/middleware/bullet_logger.rb @@ -1,25 +1,25 @@ -# class BulletLogger -# def initialize(app) -# @app = app -# end +class BulletLogger + def initialize(app) + @app = app + end -# def call(env) -# warnings = [] -# subscriber = ActiveSupport::Notifications.subscribe('n_plus_one_query') do |event| -# warnings << event.payload[:message] rescue nil -# end + def call(env) + warnings = [] + subscriber = ActiveSupport::Notifications.subscribe('n_plus_one_query') do |event| + warnings << event.payload[:message] rescue nil + end -# status, headers, response = @app.call(env) + status, headers, response = @app.call(env) -# ActiveSupport::Notifications.unsubscribe(subscriber) + ActiveSupport::Notifications.unsubscribe(subscriber) -# if warnings.any? -# headers['X-N-Plus-One-Warnings'] = warnings.to_json -# end + if warnings.any? + headers['X-N-Plus-One-Warnings'] = warnings.to_json + end -# [status, headers, response] -# rescue => e -# Rails.logger.error "BulletLogger Error: #{e.message}" -# @app.call(env) # Fallback to original request -# end -# end \ No newline at end of file + [status, headers, response] + rescue => e + Rails.logger.error "BulletLogger Error: #{e.message}" + @app.call(env) # Fallback to original request + end +end \ No newline at end of file From 72fbc487d2923887607b6f97d4f0ecad437e07a7 Mon Sep 17 00:00:00 2001 From: Aung Kyaw Phyo Date: Tue, 5 Aug 2025 16:32:21 +0700 Subject: [PATCH 2/7] Refactor un-mute list section --- app/views/communities/_form_step4.html.haml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/communities/_form_step4.html.haml b/app/views/communities/_form_step4.html.haml index 695230db..7abae12e 100644 --- a/app/views/communities/_form_step4.html.haml +++ b/app/views/communities/_form_step4.html.haml @@ -60,13 +60,16 @@ %td{ style: 'width: 10%;' } %img{ alt: "", src: account.avatar_url, class: "rounded-circle mr-2", style: "width: 70px; height: 70px; border: 2px solid white;" } %td{ style: 'width: 80%;' } - %h6.mb-0= account.username - %p.text-muted.mb-0= raw(account.note) - %td{ style: 'width: 10%;' } + = render_custom_emojis(account.display_name) + - domain = account&.domain.present? ? "https://#{account.domain}" : ENV.fetch('MASTODON_INSTANCE_URL', nil) + %br + %a{ href: "#{account.url}", target: "_blank" }= "@#{account.username}@#{account.domain || 'channel.org'}" + %td{style: "width: 60px;"} = form_with url: unmute_contributor_community_path, method: :post, remote: true, authenticity_token: true do |form| = form.hidden_field :account_id, value: account.id %button.btn.btn-sm.btn-outline-secondary{ type: 'submit' } Unmute + .pagination.pagination-sm.m-0.float-right = paginate @muted_accounts, theme: 'bootstrap4' From 506df70353c19ee7ce3ba7bab4c3e60e0b704cd3 Mon Sep 17 00:00:00 2001 From: Aung Kyaw Phyo Date: Tue, 5 Aug 2025 16:51:44 +0700 Subject: [PATCH 3/7] Modify search logic --- app/javascript/custom_js/search_mute_contributor.js | 2 +- app/services/contributor_search_service.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/custom_js/search_mute_contributor.js b/app/javascript/custom_js/search_mute_contributor.js index 091cd779..2de6a3ed 100644 --- a/app/javascript/custom_js/search_mute_contributor.js +++ b/app/javascript/custom_js/search_mute_contributor.js @@ -44,7 +44,7 @@ function displaySearchResults(accounts, communityId) {
-

${account.display_name || account.username}

+

${account.display_name_with_emojis || account.username}

@${account.username}@${account.domain} ${account.note ? `${account.note}` : ''}
diff --git a/app/services/contributor_search_service.rb b/app/services/contributor_search_service.rb index 50383602..3d6959a0 100644 --- a/app/services/contributor_search_service.rb +++ b/app/services/contributor_search_service.rb @@ -42,6 +42,7 @@ def find_saved_accounts_with_retry(accounts) 'id' => account.id.to_s, 'username' => account.username, 'display_name' => account.display_name, + 'display_name_with_emojis' => render_custom_emojis(account.display_name), 'domain' => account.domain, 'note' => account.note, 'avatar_url' => account.avatar_url, From 187fe6be32b98bc188796ee619ce41a43706a9d7 Mon Sep 17 00:00:00 2001 From: Aung Kyaw Phyo Date: Tue, 5 Aug 2025 17:13:32 +0700 Subject: [PATCH 4/7] Call the helper --- app/services/contributor_search_service.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/contributor_search_service.rb b/app/services/contributor_search_service.rb index 3d6959a0..0035744a 100644 --- a/app/services/contributor_search_service.rb +++ b/app/services/contributor_search_service.rb @@ -1,4 +1,7 @@ class ContributorSearchService + include ActionView::Helpers::TextHelper + include ApplicationHelper + def initialize(query, options = {}) @query = query @api_base_url = options[:url] From 13bc3beaa3126754a41c42b36bd38be9c62c402d Mon Sep 17 00:00:00 2001 From: Aung Kyaw Phyo Date: Tue, 5 Aug 2025 17:25:01 +0700 Subject: [PATCH 5/7] Add missing helper file --- app/services/contributor_search_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/contributor_search_service.rb b/app/services/contributor_search_service.rb index 0035744a..99196524 100644 --- a/app/services/contributor_search_service.rb +++ b/app/services/contributor_search_service.rb @@ -1,7 +1,8 @@ class ContributorSearchService include ActionView::Helpers::TextHelper + include ActionView::Helpers::AssetTagHelper include ApplicationHelper - + def initialize(query, options = {}) @query = query @api_base_url = options[:url] From e0da4b2d18a4d1928535b82488320f032de713b3 Mon Sep 17 00:00:00 2001 From: Aung Kyaw Phyo Date: Tue, 5 Aug 2025 17:40:41 +0700 Subject: [PATCH 6/7] Unify the result --- app/javascript/custom_js/search_mute_contributor.js | 2 +- app/services/contributor_search_service.rb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/javascript/custom_js/search_mute_contributor.js b/app/javascript/custom_js/search_mute_contributor.js index 2de6a3ed..a7707bde 100644 --- a/app/javascript/custom_js/search_mute_contributor.js +++ b/app/javascript/custom_js/search_mute_contributor.js @@ -44,7 +44,7 @@ function displaySearchResults(accounts, communityId) {
-

${account.display_name_with_emojis || account.username}

+

${account.display_name_with || account.username}

@${account.username}@${account.domain} ${account.note ? `${account.note}` : ''}
diff --git a/app/services/contributor_search_service.rb b/app/services/contributor_search_service.rb index 99196524..9b2be7ce 100644 --- a/app/services/contributor_search_service.rb +++ b/app/services/contributor_search_service.rb @@ -45,8 +45,7 @@ def find_saved_accounts_with_retry(accounts) { 'id' => account.id.to_s, 'username' => account.username, - 'display_name' => account.display_name, - 'display_name_with_emojis' => render_custom_emojis(account.display_name), + 'display_name' => render_custom_emojis(account.display_name), 'domain' => account.domain, 'note' => account.note, 'avatar_url' => account.avatar_url, From b62408a30846ac83703ebfcfbafc7dac1c519321 Mon Sep 17 00:00:00 2001 From: Aung Kyaw Phyo Date: Tue, 5 Aug 2025 17:50:22 +0700 Subject: [PATCH 7/7] Fix typo issue --- app/javascript/custom_js/search_mute_contributor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/custom_js/search_mute_contributor.js b/app/javascript/custom_js/search_mute_contributor.js index a7707bde..091cd779 100644 --- a/app/javascript/custom_js/search_mute_contributor.js +++ b/app/javascript/custom_js/search_mute_contributor.js @@ -44,7 +44,7 @@ function displaySearchResults(accounts, communityId) {
-

${account.display_name_with || account.username}

+

${account.display_name || account.username}

@${account.username}@${account.domain} ${account.note ? `${account.note}` : ''}