Class: Cli::ModelsCommand

Inherits:
Thor
  • Object
show all
Defined in:
app/lib/cli/models_command.rb

Constant Summary collapse

DESCRIPTION =
"manage models"

Instance Method Summary collapse

Instance Method Details

#pregenerate_downloads ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/lib/cli/models_command.rb', line 16

def pregenerate_downloads
  if !SiteSettings.pregenerate_downloads
    puts "ERROR: Enable proactive ZIP download creation in admin settings."
    return
  end
  scope = Model
  scope = Search::ModelSearchService.new(scope).search(options[:search]) if options[:search]
  scope.find_each do
    it.pregenerate_downloads delay: 5.seconds, queue: :low
    print "."
    sleep 0.01 # Slows down connections a bit so as not to saturate Redis
  end
  puts "\n#{scope.count} models queued for download creation" # rubocop:disable Pundit/UsePolicyScope
end

#set_permissions ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'app/lib/cli/models_command.rb', line 34

def set_permissions
  scope = Model
  scope = Search::ModelSearchService.new(scope).search(options[:search]) if options[:search]
  scope.find_each do
    it.update permission_preset: options[:preset].to_sym
    print "."
    sleep 0.01 # Slows down connections a bit so as not to saturate Redis
  end
  puts "\n#{scope.count} model permissions set to #{options[:preset]}" # rubocop:disable Pundit/UsePolicyScope
end

#update_metadata ⇒ Object



10
11
12
# File 'app/lib/cli/models_command.rb', line 10

def 
  Scan::CheckAllJob.perform_later({q: options[:search].presence}, nil)
end