mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Don't double check if contact can be archived when ran via Task
This commit is contained in:
parent
816102130b
commit
11fc484270
3 changed files with 7 additions and 5 deletions
|
@ -17,8 +17,10 @@ module Concerns
|
|||
inactive
|
||||
end
|
||||
|
||||
def archive
|
||||
raise 'Contact cannot be archived' unless archivable?(post: true)
|
||||
def archive(verified: false)
|
||||
unless verified
|
||||
raise 'Contact cannot be archived' unless archivable?(post: true)
|
||||
end
|
||||
|
||||
destroy!
|
||||
end
|
||||
|
|
|
@ -5,11 +5,11 @@ class InactiveContacts
|
|||
@contacts = contacts
|
||||
end
|
||||
|
||||
def archive
|
||||
def archive(verified: false)
|
||||
contacts.each do |contact|
|
||||
log("Archiving contact: id(#{contact.id}), code(#{contact.code})")
|
||||
|
||||
contact.archive
|
||||
contact.archive(verified: verified)
|
||||
yield contact if block_given?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace :contacts do
|
|||
task archive: :environment do
|
||||
puts 'Starting to gather archivable contacts'
|
||||
inactive_contacts = InactiveContacts.new
|
||||
archived_contacts = inactive_contacts.archive
|
||||
archived_contacts = inactive_contacts.archive(verified: true)
|
||||
|
||||
puts "Archived total: #{archived_contacts.count}"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue