@@ -94,9 +94,7 @@ protected function configure()
9494 ->addOption ('type ' , null , InputOption::VALUE_OPTIONAL , 'The type to repopulate ' )
9595 ->addOption ('no-reset ' , null , InputOption::VALUE_NONE , 'Do not reset index before populating ' )
9696 ->addOption ('no-delete ' , null , InputOption::VALUE_NONE , 'Do not delete index after populate ' )
97- ->addOption ('offset ' , null , InputOption::VALUE_REQUIRED , '[DEPRECATED] Start indexing at offset ' , 0 )
9897 ->addOption ('sleep ' , null , InputOption::VALUE_REQUIRED , 'Sleep time between persisting iterations (microseconds) ' , 0 )
99- ->addOption ('batch-size ' , null , InputOption::VALUE_REQUIRED , '[DEPRECATED] Index packet size (overrides provider config option) ' )
10098 ->addOption ('ignore-errors ' , null , InputOption::VALUE_NONE , 'Do not stop on errors ' )
10199 ->addOption ('no-overwrite-format ' , null , InputOption::VALUE_NONE , 'Prevent this command from overwriting ProgressBar \'s formats ' )
102100
@@ -132,7 +130,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
132130 'delete ' => $ delete ,
133131 'reset ' => $ reset ,
134132 'ignore_errors ' => $ input ->getOption ('ignore-errors ' ),
135- 'offset ' => $ input ->getOption ('offset ' ),
136133 'sleep ' => $ input ->getOption ('sleep ' ),
137134 'first_page ' => $ input ->getOption ('first-page ' ),
138135 'max_per_page ' => $ input ->getOption ('max-per-page ' ),
@@ -142,11 +139,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
142139 $ options ['last_page ' ] = $ input ->getOption ('last-page ' );
143140 }
144141
145- if ($ input ->getOption ('batch-size ' )) {
146- $ options ['batch_size ' ] = (int ) $ input ->getOption ('batch-size ' );
147- }
148-
149- if ($ input ->isInteractive () && $ reset && $ input ->getOption ('offset ' )) {
142+ if ($ input ->isInteractive () && $ reset && 1 < $ input ->getOption ('first_page ' )) {
150143 /** @var QuestionHelper $dialog */
151144 $ dialog = $ this ->getHelperSet ()->get ('question ' );
152145 if (!$ dialog ->ask ($ input , $ output , new Question ('<question>You chose to reset the index and start indexing with an offset. Do you really want to do that?</question> ' ))) {
@@ -220,35 +213,33 @@ private function populateIndexType(OutputInterface $output, $index, $type, $rese
220213 $ this ->resetter ->resetIndexType ($ index , $ type );
221214 }
222215
223- $ offset = $ options ['offset ' ] ;
216+ $ offset = 1 < $ options ['first_page ' ] ? ( $ options [ ' first_page ' ] - 1 ) * $ options [ ' max_per_page ' ] : 0 ;
224217 $ loggerClosure = ProgressClosureBuilder::build ($ output , 'Populating ' , $ index , $ type , $ offset );
225218
226- if ($ loggerClosure ) {
227- $ this ->dispatcher ->addListener (
228- Events::ON_EXCEPTION ,
229- function (OnExceptionEvent $ event ) use ($ loggerClosure , $ options ) {
230- $ loggerClosure (
231- $ options ['batch_size ' ],
232- count ($ event ->getObjects ()),
233- sprintf ('<error>%s</error> ' , $ event ->getException ()->getMessage ())
234- );
235- }
236- );
219+ $ this ->dispatcher ->addListener (
220+ Events::ON_EXCEPTION ,
221+ function (OnExceptionEvent $ event ) use ($ loggerClosure ) {
222+ $ loggerClosure (
223+ count ($ event ->getObjects ()),
224+ $ event ->getPager ()->getNbResults (),
225+ sprintf ('<error>%s</error> ' , $ event ->getException ()->getMessage ())
226+ );
227+ }
228+ );
237229
238- $ this ->dispatcher ->addListener (
239- Events::POST_INSERT_OBJECTS ,
240- function (PostInsertObjectsEvent $ event ) use ($ loggerClosure ) {
241- $ loggerClosure (count ($ event ->getObjects ()), $ event ->getPager ()->getNbResults ());
242- }
243- );
230+ $ this ->dispatcher ->addListener (
231+ Events::POST_INSERT_OBJECTS ,
232+ function (PostInsertObjectsEvent $ event ) use ($ loggerClosure ) {
233+ $ loggerClosure (count ($ event ->getObjects ()), $ event ->getPager ()->getNbResults ());
234+ }
235+ );
244236
245- $ this ->dispatcher ->addListener (
246- Events::POST_ASYNC_INSERT_OBJECTS ,
247- function (PostAsyncInsertObjectsEvent $ event ) use ($ loggerClosure ) {
248- $ loggerClosure ($ event ->getObjectsCount (), $ event ->getPager ()->getNbResults (), $ event ->getErrorMessage ());
249- }
250- );
251- }
237+ $ this ->dispatcher ->addListener (
238+ Events::POST_ASYNC_INSERT_OBJECTS ,
239+ function (PostAsyncInsertObjectsEvent $ event ) use ($ loggerClosure ) {
240+ $ loggerClosure ($ event ->getObjectsCount (), $ event ->getPager ()->getNbResults (), $ event ->getErrorMessage ());
241+ }
242+ );
252243
253244 if ($ options ['ignore_errors ' ]) {
254245 $ this ->dispatcher ->addListener (Events::ON_EXCEPTION , function (OnExceptionEvent $ event ) {
0 commit comments