Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
a5c696d5a9c1
Commit
5595d737
authored
Oct 05, 2017
by
Rubén Dávila
Browse files
Small refactor and fix for RuboCop
parent
4e47f279a541
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/models/gpg_signature.rb
View file @
a5c696d5
...
...
@@ -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
...
...
db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb
View file @
a5c696d5
...
...
@@ -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
_batch
es
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment