ActiveAdmin在开发环境中非常缓慢

问题描述 投票:1回答:1

我有一个应用程序,使用ActiveAdmin gem。我们实际上有3个命名空间和100多个 ActiveAdmin.register Modelrails 5.0.7activeadmin 2.4

这个应用在生产中运行的还不错,但是当我们在开发模式下,每次代码变化的时候,重载都很慢。

我深究了一下,似乎代码在 "浏览器请求 "的html部分开始重载一次,但之后页面要求的每个asset都会重载多次。而且是在同一时间。代码一次重载很多次,重载速度开始变得很慢。

这里是我刚刚进行代码修改时的输出日志。

Started GET "/admin/tickets" for ::1 at 2020-04-21 11:35:23 +0200
Creating scope :customer_relations. Overwriting existing method AdminUser.customer_relations.
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: already initialized constant ActiveAdmin::CSVBuilder::DEFAULT_COLUMNS_OPTIONS
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: previous definition of DEFAULT_COLUMNS_OPTIONS was here
Processing by Admin::TicketsController#index as HTML
  AdminUser Load (4.8ms)  SELECT  "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = $1 ORDER BY "admin_users"."id" ASC LIMIT $2  [["id", 1], ["LIMIT", 1]]
  Rendering /Users/baptibenz/.rvm/gems/ruby-2.4.4/gems/activeadmin-2.4.0/app/views/active_admin/resource/index.html.arb
   (2.3ms)  SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM "tickets" LIMIT $1 OFFSET $2) subquery_for_count  [["LIMIT", 30], ["OFFSET", 0]]
  CACHE (0.0ms)  SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM "tickets" LIMIT $1 OFFSET $2) subquery_for_count  [["LIMIT", 30], ["OFFSET", 0]]
   (2.1ms)  SELECT COUNT(*) FROM "tickets"
  CACHE (0.0ms)  SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM "tickets" LIMIT $1 OFFSET $2) subquery_for_count  [["LIMIT", 30], ["OFFSET", 0]]
  Ticket Load (2.6ms)  SELECT  "tickets".* FROM "tickets" ORDER BY "tickets"."id" desc LIMIT $1 OFFSET $2  [["LIMIT", 30], ["OFFSET", 0]]
  Listing Load (2.9ms)  SELECT  "listings".* FROM "listings" WHERE "listings"."id" = $1 LIMIT $2  [["id", 22015], ["LIMIT", 1]]
  Team Load (2.1ms)  SELECT  "teams".* FROM "teams" WHERE "teams"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
  TicketCategory Load (9.6ms)  SELECT  "ticket_categories".* FROM "ticket_categories" WHERE "ticket_categories"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
  Rendered admin/tickets/_index.arb (179.4ms)
  TicketCategory Load (5.0ms)  SELECT "ticket_categories".* FROM "ticket_categories"
  Team Load (3.1ms)  SELECT "teams".* FROM "teams"
  AdminUser Load (28.2ms)  SELECT "admin_users".* FROM "admin_users"
  Rendered layouts/_analytics.erb (0.7ms)
  Rendered /Users/baptibenz/.rvm/gems/ruby-2.4.4/gems/activeadmin-2.4.0/app/views/active_admin/resource/index.html.arb (470.9ms)
Completed 200 OK in 649ms (Views: 466.9ms | ActiveRecord: 68.7ms)


   (3.1ms)  BEGIN
   (2.2ms)  COMMIT
Started GET "/assets/jquery.xdan.datetimepicker.css" for ::1 at 2020-04-21 11:35:36 +0200
Creating scope :customer_relations. Overwriting existing method AdminUser.customer_relations.
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: already initialized constant ActiveAdmin::CSVBuilder::DEFAULT_COLUMNS_OPTIONS
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: previous definition of DEFAULT_COLUMNS_OPTIONS was here
Started GET "/assets/active_admin.js" for ::1 at 2020-04-21 11:35:43 +0200
   (2.1ms)  BEGIN
   (2.0ms)  COMMIT
Creating scope :customer_relations. Overwriting existing method AdminUser.customer_relations.
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: already initialized constant ActiveAdmin::CSVBuilder::DEFAULT_COLUMNS_OPTIONS
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: previous definition of DEFAULT_COLUMNS_OPTIONS was here
Started GET "/assets/active_admin/print.css" for ::1 at 2020-04-21 11:35:54 +0200
Started GET "/assets/active_admin.css" for ::1 at 2020-04-21 11:35:54 +0200
   (3.4ms)  BEGIN
   (2.5ms)  COMMIT
Creating scope :customer_relations. Overwriting existing method AdminUser.customer_relations.
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: already initialized constant ActiveAdmin::CSVBuilder::DEFAULT_COLUMNS_OPTIONS
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: previous definition of DEFAULT_COLUMNS_OPTIONS was here
Creating scope :customer_relations. Overwriting existing method AdminUser.customer_relations.
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: already initialized constant ActiveAdmin::CSVBuilder::DEFAULT_COLUMNS_OPTIONS
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: previous definition of DEFAULT_COLUMNS_OPTIONS was here
   (2.4ms)  BEGIN
   (4.5ms)  BEGIN
   (5.2ms)  COMMIT
   (3.8ms)  COMMIT
Started GET "/assets/active_admin/orderable.png" for ::1 at 2020-04-21 11:36:35 +0200
Creating scope :customer_relations. Overwriting existing method AdminUser.customer_relations.
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: already initialized constant ActiveAdmin::CSVBuilder::DEFAULT_COLUMNS_OPTIONS
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: previous definition of DEFAULT_COLUMNS_OPTIONS was here
Started GET "/assets/active_admin/nested_menu_arrow.gif" for ::1 at 2020-04-21 11:36:56 +0200
   (3.1ms)  BEGIN
   (3.1ms)  COMMIT
Creating scope :customer_relations. Overwriting existing method AdminUser.customer_relations.
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: already initialized constant ActiveAdmin::CSVBuilder::DEFAULT_COLUMNS_OPTIONS
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: previous definition of DEFAULT_COLUMNS_OPTIONS was here
Started GET "/assets/[email protected]" for ::1 at 2020-04-21 11:37:19 +0200
   (2.9ms)  BEGIN
   (2.5ms)  COMMIT
Creating scope :customer_relations. Overwriting existing method AdminUser.customer_relations.
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: already initialized constant ActiveAdmin::CSVBuilder::DEFAULT_COLUMNS_OPTIONS
/Users/baptibenz/dev/backend/app/admin/lib/component.rb:3: warning: previous definition of DEFAULT_COLUMNS_OPTIONS was here
   (2.2ms)  BEGIN
   (4.9ms)  COMMIT

如你所见,在日期上,它非常慢。

如果您需要更多的信息,请告诉我 :-)

ruby-on-rails ruby ruby-on-rails-5 activeadmin reload
1个回答
0
投票

看起来你已经遇到了 ActiveAdmin#5787. TL;DR这个问题在Rails 5.2和ActiveAdmin 2.6中消失了。

© www.soinside.com 2019 - 2024. All rights reserved.