mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 11:42:19 -05:00
32 lines
1.1 KiB
Ruby
32 lines
1.1 KiB
Ruby
require "thor"
|
|
|
|
module Cli
|
|
class ModelsCommand < Thor
|
|
namespace :models
|
|
DESCRIPTION = "manage models"
|
|
|
|
desc "update_metadata", "reruns the metadata parser for all models"
|
|
option :search, required: false, type: :string
|
|
def update_metadata
|
|
Scan::CheckAllJob.perform_later({q: options[:search].presence}, nil)
|
|
end
|
|
|
|
desc "pregenerate_downloads", "generate downloadable ZIP files for all models"
|
|
option :search, required: false, type: :string
|
|
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|
|
|
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
|
|
end
|
|
end
|