Conversation
| end | ||
|
|
||
| def create_seed_security_groups(config) | ||
| return unless config.get(:security_group_definitions) && SecurityGroup.count == 0 |
There was a problem hiding this comment.
Rubocop gave a bad advice here. On a model/dataset we should use empty? as this issues an optimized SQL query. The none? function is implemented in Enumerable, thus all entries are fetched to check if there is any. count and empty? are Sequel functions instead:
.count == 0 => SELECT count(*) AS "count" FROM "security_groups" LIMIT 1
.none? => SELECT * FROM "security_groups"
.empty? => SELECT 1 AS\"one" FROM "security_groups" LIMIT 1
The other good function besides empty? is any? as we use the any_not_empty extension. All other Enumerable functions should be used with care on a model/dataset.
| where(Sequel.lit("run_at < CURRENT_TIMESTAMP - INTERVAL '?' DAY", force_delete_after)) | ||
|
|
||
| unless orphaned_delayed_jobs.count.zero? | ||
| unless orphaned_delayed_jobs.none? |
There was a problem hiding this comment.
Can be changed to if orphaned_delayed_jobs.any?.
|
|
||
| started_app_count = ProcessModel.where(state: 'STARTED').count | ||
|
|
||
| expect(AppUsageEvent.count > 1).to be true |
There was a problem hiding this comment.
many? also issues a SELECT * FROM ... - so here count seems to be the better option.
| end | ||
|
|
||
| def validate_remove_billing_manager_by_guid!(org) | ||
| return if org.billing_managers_dataset.count > 1 |
There was a problem hiding this comment.
many? and one? also issue a SELECT * FROM ... - so here count seems to be the better option.
|
Actually I like using |
Would you prefer I remove the commit for this Also I definitely didn't think about what queries would actually be so thanks for calling that out |
👍 I agree that this would be the easiest option for now. |
This reverts commit 3e1ffbc.
|
Reverted, should be good to go now |
Changes in cloud_controller_ng:
- Some Rubocop fixes
PR: cloudfoundry/cloud_controller_ng#4595
Author: M. Oleske <moleske@users.noreply.github.com>
Thanks for contributing to cloud_controller_ng. To speed up the process of reviewing your pull request please provide us with:
A short explanation of the proposed change:
fix the easy rubocop issues
An explanation of the use cases your change solves
less output when running rubocop
Links to any other associated PRs
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
mainbranchI have run all the unit tests using
bundle exec rakeI have run CF Acceptance Tests