@@ -127,13 +127,12 @@ private function addGeonamesDocuments(Index $index, OutputInterface $output)
127
127
___SQL );
128
128
129
129
$ count = ($ stmt ->fetchNumeric ())[0 ];
130
- $ this ->io ->note ($ count );
130
+ if ($ count !== 0 ) {
131
+ $ progressBar = $ this ->getProgressBar ($ output , $ count );
131
132
132
- $ progressBar = $ this ->getProgressBar ($ output , $ count );
133
-
134
- $ firstResult = 0 ;
135
- do {
136
- $ query = $ this ->entityManager ->createNativeQuery (<<<___SQL
133
+ $ firstResult = 0 ;
134
+ do {
135
+ $ query = $ this ->entityManager ->createNativeQuery (<<<___SQL
137
136
SELECT
138
137
g.geonameid AS geonameid,
139
138
g.`name` AS name,
@@ -162,15 +161,16 @@ private function addGeonamesDocuments(Index $index, OutputInterface $output)
162
161
ON (g.geonameid = membercounts.IdCity)
163
162
LIMIT {$ firstResult }, {$ this ->chunkSize }
164
163
___SQL
165
- , $ this ->getResultSetMappingForGeonamesIndex ());
164
+ , $ this ->getResultSetMappingForGeonamesIndex ());
166
165
167
- $ addDocumentsCount = $ this ->addGeonamesDocumentsToIndex ($ index , $ query , $ progressBar );
166
+ $ addDocumentsCount = $ this ->addGeonamesDocumentsToIndex ($ index , $ query , $ progressBar );
168
167
169
- $ firstResult += $ this ->chunkSize ;
170
- } while ($ addDocumentsCount > 0 );
168
+ $ firstResult += $ this ->chunkSize ;
169
+ } while ($ addDocumentsCount > 0 );
171
170
172
- $ progressBar ->finish ();
173
- $ this ->io ->newLine ();
171
+ $ progressBar ->finish ();
172
+ $ this ->io ->newLine ();
173
+ }
174
174
}
175
175
176
176
private function addAlternateNamesDocuments (Index $ index , OutputInterface $ output )
@@ -188,13 +188,13 @@ private function addAlternateNamesDocuments(Index $index, OutputInterface $outpu
188
188
___SQL );
189
189
190
190
$ count = ($ stmt ->fetchNumeric ())[0 ];
191
+ if ($ count !== 0 ) {
192
+ $ progressBar = $ this ->getProgressBar ($ output , $ count );
193
+ $ progressBar ->start ();
191
194
192
- $ progressBar = $ this ->getProgressBar ($ output , $ count );
193
- $ progressBar ->start ();
194
-
195
- $ firstResult = 0 ;
196
- do {
197
- $ query = $ this ->entityManager ->createNativeQuery (<<<___SQL
195
+ $ firstResult = 0 ;
196
+ do {
197
+ $ query = $ this ->entityManager ->createNativeQuery (<<<___SQL
198
198
SELECT
199
199
g.geonameid,
200
200
gt.`content` AS name,
@@ -225,15 +225,16 @@ private function addAlternateNamesDocuments(Index $index, OutputInterface $outpu
225
225
ON (g.geonameid = membercounts.IdCity)
226
226
LIMIT {$ firstResult }, {$ this ->chunkSize }
227
227
___SQL
228
- , $ this ->getResultSetMappingForGeonamesIndex ());
228
+ , $ this ->getResultSetMappingForGeonamesIndex ());
229
229
230
- $ addDocumentsCount = $ this ->addGeonamesDocumentsToIndex ($ index , $ query , $ progressBar );
230
+ $ addDocumentsCount = $ this ->addGeonamesDocumentsToIndex ($ index , $ query , $ progressBar );
231
231
232
- $ firstResult += $ this ->chunkSize ;
233
- } while ($ addDocumentsCount > 0 );
232
+ $ firstResult += $ this ->chunkSize ;
233
+ } while ($ addDocumentsCount > 0 );
234
234
235
- $ progressBar ->finish ();
236
- $ this ->io ->newLine ();
235
+ $ progressBar ->finish ();
236
+ $ this ->io ->newLine ();
237
+ }
237
238
}
238
239
239
240
private function addGeonamesDocumentsToIndex (Index $ index , NativeQuery $ query , ProgressBar $ progress ): int
@@ -255,16 +256,16 @@ private function addGeonamesDocumentsToIndex(Index $index, NativeQuery $query, P
255
256
$ documents [] = [
256
257
'geoname_id ' => $ location ['geonameid ' ],
257
258
'name ' => $ location ['name ' ],
258
- 'country ' => $ location ['country ' ],
259
+ 'country ' => $ location ['country ' ] ?? 0 ,
259
260
'isPlace ' => $ isPlace ,
260
261
'isAdmin ' => $ isAdmin ,
261
262
'isCountry ' => $ isCountry ,
262
263
'locale ' => $ this ->adaptLocale ($ location ['locale ' ]),
263
- 'admin1 ' => $ location ['admin1 ' ],
264
- 'admin2 ' => $ location ['admin2 ' ],
265
- 'admin3 ' => $ location ['admin3 ' ],
266
- 'admin4 ' => $ location ['admin4 ' ],
267
- 'population ' => $ location ['population ' ],
264
+ 'admin1 ' => $ location ['admin1 ' ] ?? 0 ,
265
+ 'admin2 ' => $ location ['admin2 ' ] ?? 0 ,
266
+ 'admin3 ' => $ location ['admin3 ' ] ?? 0 ,
267
+ 'admin4 ' => $ location ['admin4 ' ] ?? 0 ,
268
+ 'population ' => $ location ['population ' ] ?? 0 ,
268
269
'member_count ' => $ location ['member_count ' ],
269
270
];
270
271
$ progress ->advance ();
0 commit comments