Commit 5595d737 authored by Rubén Dávila's avatar Rubén Dávila

Small refactor and fix for RuboCop

parent bd8e3606
......@@ -22,14 +22,11 @@ class GpgSignature < ActiveRecord::Base
validates :gpg_key_primary_keyid, presence: true
def self.with_key_and_subkeys(gpg_key)
return none unless gpg_key
t = arel_table
subkey_ids = gpg_key&.subkeys&.pluck(:id)
subkey_ids = gpg_key.subkeys.pluck(:id)
where(
t[:gpg_key_id].eq(gpg_key&.id).or(
t[:gpg_key_subkey_id].in(subkey_ids)
arel_table[:gpg_key_id].eq(gpg_key.id).or(
arel_table[:gpg_key_subkey_id].in(subkey_ids)
)
)
end
......
......@@ -8,11 +8,13 @@ class ScheduleCreateGpgKeySubkeysFromGpgKeys < ActiveRecord::Migration
class GpgKey < ActiveRecord::Base
self.table_name = 'gpg_keys'
include EachBatch
end
def up
GpgKey.select(:id).in_batches do |relation|
jobs = relation.pluck(:id).map do |id|
GpgKey.select(:id).each_batch do |gpg_keys|
jobs = gpg_keys.pluck(:id).map do |id|
['CreateGpgKeySubkeysFromGpgKeys', [id]]
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment