ActiveAdmin在开发环境中非常缓慢



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

该应用程序在生产中运行得很好,但当我们处于开发模式时,每次代码更改,重新加载都非常缓慢。

反射轨迹可能不相关:我深入研究了一下,似乎代码开始为"浏览器请求"的html部分重新加载一次,但之后它为页面要求的每个资产重新加载多次。同时也是如此。代码一次重新加载了很多次,重新加载开始非常缓慢。

这里是我刚修改代码时的输出日志:

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/chosen-sprite@2x.png" 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

正如你在日期中看到的,非常慢

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

看起来您已经运行了ActiveAdmin#5787。TL;DR在Rails 5.2和ActiveAdmin 2.6中都消失了。

相关内容

  • 没有找到相关文章

最新更新