Skip to content

Commit a8705f5

Browse files
Gargronhiyuki2578
authored andcommitted
Add tootctl search deploy to avoid ugly rake task syntax (mastodon#10403)
1 parent af28618 commit a8705f5

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

lib/cli.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require_relative 'mastodon/emoji_cli'
66
require_relative 'mastodon/accounts_cli'
77
require_relative 'mastodon/feeds_cli'
8+
require_relative 'mastodon/search_cli'
89
require_relative 'mastodon/settings_cli'
910
require_relative 'mastodon/statuses_cli'
1011
require_relative 'mastodon/domains_cli'
@@ -28,6 +29,9 @@ def self.exit_on_failure?
2829
desc 'feeds SUBCOMMAND ...ARGS', 'Manage feeds'
2930
subcommand 'feeds', Mastodon::FeedsCLI
3031

32+
desc 'search SUBCOMMAND ...ARGS', 'Manage the search engine'
33+
subcommand 'search', Mastodon::SearchCLI
34+
3135
desc 'settings SUBCOMMAND ...ARGS', 'Manage dynamic settings'
3236
subcommand 'settings', Mastodon::SettingsCLI
3337

lib/mastodon/search_cli.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../../config/boot'
4+
require_relative '../../config/environment'
5+
require_relative 'cli_helper'
6+
7+
module Mastodon
8+
class SearchCLI < Thor
9+
desc 'deploy', 'Create or update an ElasticSearch index and populate it'
10+
long_desc <<~LONG_DESC
11+
If ElasticSearch is empty, this command will create the necessary indices
12+
and then import data from the database into those indices.
13+
14+
This command will also upgrade indices if the underlying schema has been
15+
changed since the last run.
16+
LONG_DESC
17+
def deploy
18+
processed = Chewy::RakeHelper.upgrade
19+
Chewy::RakeHelper.sync(except: processed)
20+
end
21+
end
22+
end

0 commit comments

Comments
 (0)