Skip to content

Commit

Permalink
update prefix rake tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 16, 2020
1 parent 1e86cad commit 06250e1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ def list_indices
# delete and create inactive index to use current mappings
# Needs to run every time we change the mappings
def upgrade_index(options = {})
inactive_index ||= (options[:index] || inactive_index)
inactive_index ||= (options[:index] || self.inactive_index)

__elasticsearch__.create_index!(index: inactive_index, force: true)
"Upgraded inactive index #{inactive_index}."
Expand Down
20 changes: 20 additions & 0 deletions lib/tasks/client_prefix.rake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ namespace :client_prefix do
puts ClientPrefix.active_index + " is the active index."
end

desc "Return inactive index for client_prefixes"
task inactive_index: :environment do
puts ClientPrefix.inactive_index + " is the inactive index."
end

desc "Monitor reindexing for client_prefixes"
task monitor_reindex: :environment do
puts ClientPrefix.monitor_reindex
Expand All @@ -41,6 +46,21 @@ namespace :client_prefix do
ClientPrefix.import(index: ENV["INDEX"] || ClientPrefix.inactive_index, batch_size: (ENV["BATCH_SIZE"] || 100).to_i)
end

desc "Create alias for client_prefixes"
task create_alias: :environment do
puts ClientPrefix.create_alias(index: ENV["INDEX"], alias: ENV["ALIAS"])
end

desc "List aliases for client_prefixes"
task list_aliases: :environment do
puts ClientPrefix.list_aliases
end

desc "Delete alias for client_prefixes"
task delete_alias: :environment do
puts ClientPrefix.delete_alias(index: ENV["INDEX"], alias: ENV["ALIAS"])
end

desc "Delete from index by query"
task delete_by_query: :environment do
if ENV["QUERY"].nil?
Expand Down
20 changes: 20 additions & 0 deletions lib/tasks/prefix.rake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ namespace :prefix do
puts Prefix.active_index + " is the active index."
end

desc "Return inactive index for prefixes"
task inactive_index: :environment do
puts Prefix.inactive_index + " is the inactive index."
end

desc "Monitor reindexing for prefixes"
task monitor_reindex: :environment do
puts Prefix.monitor_reindex
Expand All @@ -41,6 +46,21 @@ namespace :prefix do
Prefix.import(index: ENV["INDEX"] || Prefix.inactive_index, batch_size: (ENV["BATCH_SIZE"] || 100).to_i)
end

desc "Create alias for prefixes"
task create_alias: :environment do
puts Prefix.create_alias(index: ENV["INDEX"], alias: ENV["ALIAS"])
end

desc "List aliases for prefixes"
task list_aliases: :environment do
puts Prefix.list_aliases
end

desc "Delete alias for prefixes"
task delete_alias: :environment do
puts Prefix.delete_alias(index: ENV["INDEX"], alias: ENV["ALIAS"])
end

desc "Delete from index by query"
task delete_by_query: :environment do
if ENV["QUERY"].nil?
Expand Down
20 changes: 20 additions & 0 deletions lib/tasks/provider_prefix.rake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ namespace :provider_prefix do
puts ProviderPrefix.active_index + " is the active index."
end

desc "Return inactive index for provider_prefixes"
task inactive_index: :environment do
puts ProviderPrefix.inactive_index + " is the inactive index."
end

desc "Monitor reindexing for provider_prefixes"
task monitor_reindex: :environment do
puts ProviderPrefix.monitor_reindex
Expand All @@ -41,6 +46,21 @@ namespace :provider_prefix do
ProviderPrefix.import(index: ENV["INDEX"] || ProviderPrefix.inactive_index, batch_size: (ENV["BATCH_SIZE"] || 100).to_i)
end

desc "Create alias for provider_prefixes"
task create_alias: :environment do
puts ProviderPrefix.create_alias(index: ENV["INDEX"], alias: ENV["ALIAS"])
end

desc "List aliases for provider_prefixes"
task list_aliases: :environment do
puts ProviderPrefixefix.list_aliases
end

desc "Delete alias for provider_prefixes"
task delete_alias: :environment do
puts ProviderPrefix.delete_alias(index: ENV["INDEX"], alias: ENV["ALIAS"])
end

desc "Delete from index by query"
task delete_by_query: :environment do
if ENV["QUERY"].nil?
Expand Down

0 comments on commit 06250e1

Please sign in to comment.