~cytrogen/masto-fe

bae694108a1cd9a228ae798d6fdfcd4a70a795cf — Matt Jankowski 2 years ago 9189e90
Fix Performance/Count cop (#24793)

M .rubocop_todo.yml => .rubocop_todo.yml +0 -6
@@ 309,12 309,6 @@ Performance/CollectionLiteralInLoop:
    - '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:
  Exclude:

M app/lib/importer/accounts_index_importer.rb => app/lib/importer/accounts_index_importer.rb +2 -2
@@ 6,8 6,8 @@ class Importer::AccountsIndexImporter < Importer::BaseImporter
      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)


M app/lib/importer/tags_index_importer.rb => app/lib/importer/tags_index_importer.rb +2 -2
@@ 6,8 6,8 @@ class Importer::TagsIndexImporter < Importer::BaseImporter
      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)