mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Avoid the use of :pluck on not_signed abilities
When using :pluck, ActiveRecord trigger the query immediately.
The above is a behavior we probably want to avoid, because
implies a query to the database regarless of the role or
permission.
** Before
osem_1 | 07:39:11 web.1 | Started GET "/" for 172.20.0.1 at 2019-07-1207:39:11 +0000
osem_1 | 07:39:11 web.1 | (0.3ms) SELECT
"conferences"."custom_domain" FROM "conferences" WHERE
("conferences"."custom_domain" IS NOT NULL) ORDER BY start_date DESC
osem_1 | 07:39:11 web.1 | Processing by ConferencesController#index as HTML
osem_1 | 07:39:11 web.1 | (1.3ms) SELECT "events"."id" FROM
"events" WHERE "events"."state" = $ 1 [["state", "confirmed"]]
osem_1 | 07:39:11 web.1 | ↳ app/models/ability.rb:39:in `not_signed_in'
osem_1 | 07:39:11 web.1 | Rendering layouts/application.html.haml
osem_1 | 07:39:11 web.1 | Rendering conferences/index.html.haml within layouts/application
** After
osem_1 | 07:43:18 web.1 | Started GET "/" for 172.20.0.1 at 2019-07-1207:43:18 +0000
osem_1 | 07:43:19 web.1 | (0.2ms) SELECT
"conferences"."custom_domain" FROM "conferences" WHERE
("conferences"."custom_domain" IS NOT NULL) ORDER BY start_date DESC
osem_1 | 07:43:19 web.1 | Processing by ConferencesController#index as HTML
osem_1 | 07:43:19 web.1 | Rendering layouts/application.html.haml
osem_1 | 07:43:19 web.1 | Rendering conferences/index.html.haml within layouts/application
This commit is contained in:
parent
eeec3df7aa
commit
6421916784
1 changed files with 1 additions and 1 deletions
|
|
@ -36,7 +36,7 @@ class Ability
|
|||
end
|
||||
|
||||
# can view Commercials of confirmed Events
|
||||
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
|
||||
can :show, Commercial, commercialable: Event.where(state: 'confirmed')
|
||||
can [:show, :create], User
|
||||
|
||||
can [:index, :show], Survey, surveyable_type: 'Conference'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue