Bianca Nenciu 61a0ae3755
FEATURE: Create legal topics for set company name ()
Legal topics, such as the Terms of Service and Privacy Policy topics
do not make sense if the entity creating the community is not a company.
These topics will be created and updated only when the company name is
present and deleted when it is not.
2023-05-24 23:05:36 +03:00

39 lines
1.5 KiB
Ruby

# frozen_string_literal: true
desc "ensure the asynchronously-created post_search_data index is present"
task "annotate" => :environment do |task, args|
raise if !system "bin/annotate --models"
STDERR.puts "Annotate executed successfully"
non_core_plugins =
Dir["plugins/*"].filter { |plugin_path| `git check-ignore #{plugin_path}`.present? }
if non_core_plugins.length > 0
STDERR.puts "Warning: you have non-core plugins installed which may affect the annotations"
STDERR.puts "For core annotations, consider running `bin/rake annotate:clean`"
end
end
desc "ensure the asynchronously-created post_search_data index is present"
task "annotate:ensure_all_indexes" => :environment do |task, args|
# One of the indexes on post_search_data is created by a sidekiq job
# We need to do some acrobatics to create it on-demand
SeedData::Topics.with_default_locale.create
SiteSetting.search_enable_recent_regular_posts_offset_size = 1
Jobs::CreateRecentPostSearchIndexes.new.execute([])
end
desc "regenerate core model annotations using a temporary database"
task "annotate:clean" => :environment do |task, args|
db = TemporaryDb.new
db.start
db.with_env do
raise if !system "RAILS_ENV=test LOAD_PLUGINS=0 bin/rake db:migrate"
raise if !system "RAILS_ENV=test LOAD_PLUGINS=0 bin/rake annotate:ensure_all_indexes"
raise if !system "RAILS_ENV=test LOAD_PLUGINS=0 bin/annotate --models --model-dir app/models"
end
STDERR.puts "Annotate executed successfully"
ensure
db&.stop
db&.remove
end