Fix `Rails/WhereExists` cop in app/services (#28853)

th-new
Matt Jankowski 2024-01-23 06:41:34 -05:00 committed by GitHub
parent 78ee1453f9
commit ceade78182
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 2 additions and 4 deletions

View File

@ -86,8 +86,6 @@ Rails/WhereExists:
- 'app/models/status.rb'
- 'app/policies/status_policy.rb'
- 'app/serializers/rest/announcement_serializer.rb'
- 'app/services/activitypub/fetch_remote_status_service.rb'
- 'app/services/vote_service.rb'
- 'app/workers/move_worker.rb'
- 'spec/models/account_spec.rb'
- 'spec/services/activitypub/process_collection_service_spec.rb'

View File

@ -44,7 +44,7 @@ class ActivityPub::FetchRemoteStatusService < BaseService
# If we fetched a status that already exists, then we need to treat the
# activity as an update rather than create
activity_json['type'] = 'Update' if equals_or_includes_any?(activity_json['type'], %w(Create)) && Status.where(uri: object_uri, account_id: actor.id).exists?
activity_json['type'] = 'Update' if equals_or_includes_any?(activity_json['type'], %w(Create)) && Status.exists?(uri: object_uri, account_id: actor.id)
with_redis do |redis|
discoveries = redis.incr("status_discovery_per_request:#{@request_id}")

View File

@ -19,7 +19,7 @@ class VoteService < BaseService
already_voted = true
with_redis_lock("vote:#{@poll.id}:#{@account.id}") do
already_voted = @poll.votes.where(account: @account).exists?
already_voted = @poll.votes.exists?(account: @account)
ApplicationRecord.transaction do
@choices.each do |choice|