refactor: simplify city table queries

- Removed the limit on City queries in the Ahoy Dashboard
- Updated table_for calls for least popular active and most popular inactive cities to fetch all records instead of limiting to 10

This change allows the dashboard to display all relevant cities without
artificial limits, providing a more comprehensive overview of city
activity. The previous limitations may have hidden important data for
analysis and reporting purposes.
This commit is contained in:
songtianlun 2025-02-05 14:57:08 +08:00
parent cd26313808
commit ba8957e444

View File

@ -38,7 +38,8 @@ ActiveAdmin.register_page "Ahoy Dashboard" do
columns do columns do
column do column do
panel "最冷门活跃城市" do panel "最冷门活跃城市" do
table_for City.least_popular_active.limit(10) do # table_for City.least_popular_active.limit(10) do
table_for City.least_popular_active do
column("城市") { |city| link_to(city.name, admin_city_path(city)) } column("城市") { |city| link_to(city.name, admin_city_path(city)) }
column("访问量") { |city| city.view_count } column("访问量") { |city| city.view_count }
column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") } column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
@ -55,7 +56,8 @@ ActiveAdmin.register_page "Ahoy Dashboard" do
column do column do
panel "热门未活跃城市" do panel "热门未活跃城市" do
table_for City.most_popular_inactive.limit(10) do # table_for City.most_popular_inactive.limit(10) do
table_for City.most_popular_inactive do
column("城市") { |city| link_to(city.name, admin_city_path(city)) } column("城市") { |city| link_to(city.name, admin_city_path(city)) }
column("访问量") { |city| city.view_count } column("访问量") { |city| city.view_count }
column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") } column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }