Ran
|
Files
37
|
Run time
86min
|
Badge
Embed ▾
README BADGES
|
push
travis-ci
<a href="https://github.com/RolifyCommunity/rolify/commit/<a class=hub.com/RolifyCommunity/rolify/commit/199ca1e602da831cc06e37d36e820ba26ac65970">199ca1e60<a href="https://github.com/RolifyCommunity/rolify/commit/199ca1e602da831cc06e37d36e820ba26ac65970">">Significantly optimize #without_role (#500) * :scissors: remove some obsolete code since https://github.com/RolifyCommunity/rolify/commit/</a><a class="double-link" href="https://github.com/RolifyCommunity/rolify/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://git">&lt;a class=</a>hub.com/RolifyCommunity/rolify/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://git"><a class=</a>hub.com/RolifyCommunity/rolify/commit/<a class="double-link" href="https://git"><a class=</a>hub.com/RolifyCommunity/rolify/commit/<a class=hub.com/RolifyCommunity/rolify/commit/<a class="double-link" href="https://git"><a class=hub.com/RolifyCommunity/rolify/commit/522c0d7d84a70dd3576b569edf19f9f6cb118a61">522c0d7d8">522c0d7d8</a><a href="https://github.com/RolifyCommunity/rolify/commit/199ca1e602da831cc06e37d36e820ba26ac65970"> Rails < 4 is no longer supported * significantly optimize #without_role Imagine a big production application with millions of users. The previous version generates 3 queries for `User.without_role(:admin)`: 1) For `user.all` in [`#all_except`](https://github.com/RolifyCommunity/rolify/blob/522c0d7d84a70dd3576b569edf19f9f6cb118a61/lib/rolify/adapters/active_record/role_adapter.rb#L83): ```sql SELECT "users".* FROM "users" ``` 2) For `self.with_role(role_name, resource)` in [`#without_role`](https://github.com/RolifyCommunity/rolify/blob/522c0d7d84a70dd3576b569edf19f9f6cb118a61/lib/rolify/finders.rb#L8): ```sql SELECT "users".* FROM "users" INNER JOIN "users_roles" ON "users_roles"."user_id" = "users"."id" INNER JOIN "roles" ON "roles"."id" = "users_roles"."role_id" WHERE (((roles.name = 'admin') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL))) ``` 3) For `user.where(prime_key => (user.all - excluded_obj).map(&prime_key))` in [`#all_except`](https://github... (continued)
1609 of 1740 relevant lines covered (92.47%)
49.86 hits per line
Coverage | ∆ | File | Lines | Relevant | Covered | Missed | Hits/Line |
---|