Skip to content

Commit

Permalink
Add tootctl search deploy to avoid ugly rake task syntax (mastodon#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and hiyuki2578 committed Oct 2, 2019
1 parent af28618 commit a8705f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/cli.rb
Expand Up @@ -5,6 +5,7 @@
require_relative 'mastodon/emoji_cli'
require_relative 'mastodon/accounts_cli'
require_relative 'mastodon/feeds_cli'
require_relative 'mastodon/search_cli'
require_relative 'mastodon/settings_cli'
require_relative 'mastodon/statuses_cli'
require_relative 'mastodon/domains_cli'
Expand All @@ -28,6 +29,9 @@ def self.exit_on_failure?
desc 'feeds SUBCOMMAND ...ARGS', 'Manage feeds'
subcommand 'feeds', Mastodon::FeedsCLI

desc 'search SUBCOMMAND ...ARGS', 'Manage the search engine'
subcommand 'search', Mastodon::SearchCLI

desc 'settings SUBCOMMAND ...ARGS', 'Manage dynamic settings'
subcommand 'settings', Mastodon::SettingsCLI

Expand Down
22 changes: 22 additions & 0 deletions lib/mastodon/search_cli.rb
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require_relative '../../config/boot'
require_relative '../../config/environment'
require_relative 'cli_helper'

module Mastodon
class SearchCLI < Thor
desc 'deploy', 'Create or update an ElasticSearch index and populate it'
long_desc <<~LONG_DESC
If ElasticSearch is empty, this command will create the necessary indices
and then import data from the database into those indices.
This command will also upgrade indices if the underlying schema has been
changed since the last run.
LONG_DESC
def deploy
processed = Chewy::RakeHelper.upgrade
Chewy::RakeHelper.sync(except: processed)
end
end
end

0 comments on commit a8705f5

Please sign in to comment.