casa icon indicating copy to clipboard operation
casa copied to clipboard

Fix bullet n+1 issues in tests

Open compwron opened this issue 4 years ago • 15 comments

Remove and fix each test with :disable_bullet one by one :)

compwron avatar Nov 27 '20 08:11 compwron

@littleforest Are you working on this or can I take it?

bjthompson805 avatar Jan 05 '21 01:01 bjthompson805

@bjthompson805 you can take it!

littleforest avatar Jan 05 '21 02:01 littleforest

@compwron I'm really new to Rails and wondering if you could help me figure out where this call is being made that I can add .includes([:logo_attachment]) as it is suggesting. Here is what 99% of the errors are the first time I ran with Bullet.raise = true, any help is appreciated!:

  Bullet::Notification::UnoptimizedQueryError:
    user: root
    GET /casa_cases
    USE eager loading detected
      CasaOrg => [:logo_attachment]
      Add to your query: .includes([:logo_attachment])
    Call stack
      /usr/src/app/app/views/layouts/_sidebar.html.erb:3:in `_app_views_layouts__sidebar_html_erb__493316934298706686_51240'
      /usr/src/app/app/views/layouts/application.html.erb:38:in `_app_views_layouts_application_html_erb__199189227000836964_51180'
      /usr/src/app/spec/system/casa_cases/index_spec.rb:17:in `block (2 levels) in <top (required)>'

bjthompson805 avatar Jan 07 '21 18:01 bjthompson805

@bjthompson805 these can be tricky. In this case it should go on the in_organization scope in the users model:

  scope :in_organization, lambda { |org|
    where(casa_org_id: org.id).includes(casa_org: :logo_attachment)
  }

littleforest avatar Jan 07 '21 19:01 littleforest

This issue has been inactive for 143 hours (5.96 days) and will be automatically unassigned after 25 more hours (1.04 days).

github-actions[bot] avatar Jan 11 '21 00:01 github-actions[bot]

@bjthompson805 since I commented 3 days ago, shouldn't this not get marked as inactive?

littleforest avatar Jan 11 '21 01:01 littleforest

Yeah it shouldn't. I'll look into that.

bjthompson805 avatar Jan 11 '21 01:01 bjthompson805

@littleforest I fixed the issue, let me know if you see anything else.

bjthompson805 avatar Jan 11 '21 20:01 bjthompson805

Great, thanks @bjthompson805 !

littleforest avatar Jan 11 '21 22:01 littleforest

This issue has been inactive for 123 hours (5.13 days) and will be automatically unassigned after 45 more hours (1.88 days).

github-actions[bot] avatar Jan 17 '21 01:01 github-actions[bot]

This issue has been inactive for 171 hours (7.13 days) and is past the limit of 168 hours (7.00 days) so is being unassigned.

github-actions[bot] avatar Jan 19 '21 01:01 github-actions[bot]

This issue has been open without changes for a long time! What's up?

github-actions[bot] avatar Jun 24 '21 01:06 github-actions[bot]

Has this issue been resolved?

Luke-kb avatar Sep 26 '22 23:09 Luke-kb

Nope! There was a very weird issue I found with the logo, which maybe I can pair with you if you are interested in working on this. Since the logo is loaded on pretty much every page, it was affecting nearly every spec.

littleforest avatar Sep 27 '22 00:09 littleforest

@Luke-kb maybe this has been fixed??? Not sure. It looks like Bullet.enable = true and Bullet.raise = true in the config/environments/test.rb file. There is an override for SKIP_BULLET, but it does not look like that is set in CI. Can you make sure that SKIP_BULLET is NOT set in your local .env file and that the specs run okay? I will try to look at it in more detail later too. Maybe remove an includes statement and make sure you can get the specs to trip on an N+1 issue.

littleforest avatar Sep 27 '22 16:09 littleforest

closing this for now because we don't have any bullet skips anymore!

compwron avatar Apr 07 '23 18:04 compwron