Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
53aca8ae
Unverified
Commit
53aca8ae
authored
3 years ago
by
OSAMU SATO
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add batch_size option to bin/tootctl search deploy (#17049)
parent
0909874c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/mastodon/search_cli.rb
+7
-1
7 additions, 1 deletion
lib/mastodon/search_cli.rb
with
7 additions
and
1 deletion
lib/mastodon/search_cli.rb
+
7
−
1
View file @
53aca8ae
...
...
@@ -17,6 +17,7 @@ module Mastodon
].
freeze
option
:concurrency
,
type: :numeric
,
default:
2
,
aliases:
[
:c
],
desc:
'Workload will be split between this number of threads'
option
:batch_size
,
type: :numeric
,
default:
1_000
,
aliases:
[
:b
],
desc:
'Number of records in each batch'
option
:only
,
type: :array
,
enum:
%w(accounts tags statuses)
,
desc:
'Only process these indices'
desc
'deploy'
,
'Create or upgrade ElasticSearch indices and populate them'
long_desc
<<~
LONG_DESC
...
...
@@ -35,6 +36,11 @@ module Mastodon
exit
(
1
)
end
if
options
[
:batch_size
]
<
1
say
(
'Cannot run with this batch_size setting, must be at least 1'
,
:red
)
exit
(
1
)
end
indices
=
begin
if
options
[
:only
]
options
[
:only
].
map
{
|
str
|
"
#{
str
.
camelize
}
Index"
.
constantize
}
...
...
@@ -73,7 +79,7 @@ module Mastodon
# is uneconomical. So we only ever add.
indices
.
each
do
|
index
|
progress
.
title
=
"Importing
#{
index
}
"
batch_size
=
1_000
batch_size
=
options
[
:batch_size
]
slice_size
=
(
batch_size
/
options
[
:concurrency
]).
ceil
index
.
adapter
.
default_scope
.
reorder
(
nil
).
find_in_batches
(
batch_size:
batch_size
)
do
|
batch
|
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment