Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Fix Performance/Count cop (mastodon#24793)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored May 2, 2023
1 parent 9189e90 commit bae6941
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,6 @@ Performance/CollectionLiteralInLoop:
- 'config/deploy.rb'
- 'lib/mastodon/media_cli.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Performance/Count:
Exclude:
- 'app/lib/importer/accounts_index_importer.rb'
- 'app/lib/importer/tags_index_importer.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SafeMultiline.
Performance/DeletePrefix:
Expand Down
4 changes: 2 additions & 2 deletions app/lib/importer/accounts_index_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def import!
in_work_unit(tmp) do |accounts|
bulk = Chewy::Index::Import::BulkBuilder.new(index, to_index: accounts).bulk_body

indexed = bulk.select { |entry| entry[:index] }.size
deleted = bulk.select { |entry| entry[:delete] }.size
indexed = bulk.count { |entry| entry[:index] }
deleted = bulk.count { |entry| entry[:delete] }

Chewy::Index::Import::BulkRequest.new(index).perform(bulk)

Expand Down
4 changes: 2 additions & 2 deletions app/lib/importer/tags_index_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def import!
in_work_unit(tmp) do |tags|
bulk = Chewy::Index::Import::BulkBuilder.new(index, to_index: tags).bulk_body

indexed = bulk.select { |entry| entry[:index] }.size
deleted = bulk.select { |entry| entry[:delete] }.size
indexed = bulk.count { |entry| entry[:index] }
deleted = bulk.count { |entry| entry[:delete] }

Chewy::Index::Import::BulkRequest.new(index).perform(bulk)

Expand Down

0 comments on commit bae6941

Please sign in to comment.