mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +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
|
inactive
|
||||||
end
|
end
|
||||||
|
|
||||||
def archive
|
def archive(verified: false)
|
||||||
raise 'Contact cannot be archived' unless archivable?(post: true)
|
unless verified
|
||||||
|
raise 'Contact cannot be archived' unless archivable?(post: true)
|
||||||
|
end
|
||||||
|
|
||||||
destroy!
|
destroy!
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,11 +5,11 @@ class InactiveContacts
|
||||||
@contacts = contacts
|
@contacts = contacts
|
||||||
end
|
end
|
||||||
|
|
||||||
def archive
|
def archive(verified: false)
|
||||||
contacts.each do |contact|
|
contacts.each do |contact|
|
||||||
log("Archiving contact: id(#{contact.id}), code(#{contact.code})")
|
log("Archiving contact: id(#{contact.id}), code(#{contact.code})")
|
||||||
|
|
||||||
contact.archive
|
contact.archive(verified: verified)
|
||||||
yield contact if block_given?
|
yield contact if block_given?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace :contacts do
|
||||||
task archive: :environment do
|
task archive: :environment do
|
||||||
puts 'Starting to gather archivable contacts'
|
puts 'Starting to gather archivable contacts'
|
||||||
inactive_contacts = InactiveContacts.new
|
inactive_contacts = InactiveContacts.new
|
||||||
archived_contacts = inactive_contacts.archive
|
archived_contacts = inactive_contacts.archive(verified: true)
|
||||||
|
|
||||||
puts "Archived total: #{archived_contacts.count}"
|
puts "Archived total: #{archived_contacts.count}"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue