@@ -60,10 +60,10 @@ public function runProfiles(array $query, array $profiles): array
6060
6161 if (isset ($ query ['query ' ])) {
6262 $ outputCsv = $ this ->output ->createReport ($ query );
63- $ this ->output ->createManifest ($ outputCsv ->getFilename (), $ query , ['id ' ], true );
6463 $ this ->logger ->info (sprintf ("Running query '%s' " , $ query ['outputTable ' ]));
6564
6665 $ downloadedProfiles = false ;
66+ $ manifestCreated = false ;
6767 foreach ($ profiles as $ profile ) {
6868 $ this ->logger ->info (sprintf ('Profile "%s" export started. ' , $ profile ['id ' ]));
6969 $ apiQuery = $ query ;
@@ -130,7 +130,16 @@ public function runProfiles(array $query, array $profiles): array
130130 }
131131 }
132132
133- $ paginator ->paginate ($ apiQuery , $ report , $ outputCsv );
133+ $ rowCount = $ paginator ->paginate ($ apiQuery , $ report , $ outputCsv );
134+ if ($ rowCount > 0 && !$ manifestCreated ) {
135+ $ this ->output ->createManifest (
136+ $ outputCsv ->getFilename (),
137+ $ query ,
138+ ['id ' ],
139+ true ,
140+ );
141+ $ manifestCreated = true ;
142+ }
134143
135144 $ status [$ query ['outputTable ' ]][$ profile ['id ' ]] = 'ok ' ;
136145 }
@@ -159,10 +168,10 @@ public function runProperties(array $query, array $properties): array
159168 $ query ['query ' ]['endpoint ' ] = 'properties ' ;
160169
161170 $ outputCsv = $ this ->output ->createReport ($ query );
162- $ this ->output ->createManifest ($ outputCsv ->getFilename (), $ query , ['id ' ], true , 'idProperty ' );
163171 $ this ->logger ->info (sprintf ("Running query '%s' " , $ query ['outputTable ' ]));
164172
165173 $ downloadedProperties = false ;
174+ $ manifestCreated = false ;
166175 foreach ($ properties as $ property ) {
167176 $ this ->logger ->info (sprintf ('Property "%s" export started. ' , $ property ['propertyName ' ]));
168177 if (!empty ($ query ['query ' ]['viewId ' ])
@@ -199,7 +208,17 @@ public function runProperties(array $query, array $properties): array
199208 continue ;
200209 }
201210
202- $ paginator ->paginate ($ apiQuery , $ report , $ outputCsv );
211+ $ rowCount = $ paginator ->paginate ($ apiQuery , $ report , $ outputCsv );
212+ if ($ rowCount > 0 && !$ manifestCreated ) {
213+ $ this ->output ->createManifest (
214+ $ outputCsv ->getFilename (),
215+ $ query ,
216+ ['id ' ],
217+ true ,
218+ 'idProperty ' ,
219+ );
220+ $ manifestCreated = true ;
221+ }
203222
204223 $ status [$ query ['outputTable ' ]][$ property ['propertyKey ' ]] = 'ok ' ;
205224 }
0 commit comments