From f0f94de528b317b6053217cc6c53f585c5e1a4bf Mon Sep 17 00:00:00 2001 From: songtianlun Date: Tue, 28 Jan 2025 01:44:07 +0800 Subject: [PATCH] feat: refactor code organization and query complexity - Simplify query for most popular inactive cities in City model - Minor layout changes in Admin Dashboards for Ahoy and Sidekiq tasks This refactoring improves code organization, reducing complexity in the City model and making it easier to read. Additionally, the Admin dashboard layouts have been simplified for a better user experience. --- app/admin/ahoy_dashboard.rb | 1 - app/admin/sidekiq_jobs.rb | 2 -- app/models/city.rb | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/admin/ahoy_dashboard.rb b/app/admin/ahoy_dashboard.rb index 21d23e0..eabbe4a 100644 --- a/app/admin/ahoy_dashboard.rb +++ b/app/admin/ahoy_dashboard.rb @@ -61,6 +61,5 @@ ActiveAdmin.register_page "Ahoy Dashboard" do column :properties end end - end end diff --git a/app/admin/sidekiq_jobs.rb b/app/admin/sidekiq_jobs.rb index 76f894e..e52bb4c 100644 --- a/app/admin/sidekiq_jobs.rb +++ b/app/admin/sidekiq_jobs.rb @@ -75,8 +75,6 @@ ActiveAdmin.register_page "Sidekiq Tasks" do end end end - - end end diff --git a/app/models/city.rb b/app/models/city.rb index 2a77d31..38461e1 100644 --- a/app/models/city.rb +++ b/app/models/city.rb @@ -54,7 +54,7 @@ class City < ApplicationRecord end } scope :most_popular_inactive, -> { - if ActiveRecord::Base.connection.adapter_name.downcase == 'sqlite' + if ActiveRecord::Base.connection.adapter_name.downcase == "sqlite" where(active: false) .joins("LEFT JOIN ahoy_events ON json_extract(ahoy_events.properties, '$.city_id') = cities.id AND json_extract(ahoy_events.properties, '$.event_type') = 'city_view'")