Commit 11917666 by Vladislav

#20443 Загрузка и синхронизация изображений

1 parent 72df3f8b
......@@ -45,6 +45,7 @@ class AdImagesAdd extends Command
{
$tokens = Tokens::whereHas('goalAdImagesForNotExternalForNotReserveCreate.adImage')
->where('type', '!=', Tokens::MAIN)
->where('id', 8)
->get();
foreach ($tokens as $token) {
......@@ -64,11 +65,13 @@ class AdImagesAdd extends Command
]);
}
$request = new AddAdImages();
$request->setToken($token)
->call([
'goalAdImages' => $goalAdImages,
]);
foreach ($goalAdImages->chunk(5) as $items) {
$request = new AddAdImages();
$request->setToken($token)
->call([
'goalAdImages' => $items,
]);
}
}
return 0;
......
......@@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Log;
class AddAdImages extends DirectRequest
{
protected $max_count = 1000;
protected $max_count = 100;
protected $timestamp;
/* @var Collection|GoalAdImage[] */
......@@ -61,20 +61,22 @@ class AddAdImages extends DirectRequest
Log::debug($add_result);
Log::debug($this->getParams()['AdImages'][$key]);
$goalAdImage->update([
'reserve_create_at' => null,
]);
$goalAdImage->where('id', $goalAdImage->getKey())
->update([
'reserve_create_at' => null,
]);
continue;
}
$hash = (string)$add_result['AdImageHash'];
$goalAdImage->update([
'hash' => $hash,
'external_upload_at' => Carbon::now(),
'reserve_create_at' => null,
]);
$goalAdImage->where('id', $goalAdImage->getKey())
->update([
'hash' => $hash,
'external_upload_at' => Carbon::now(),
'reserve_create_at' => null,
]);
}
} catch (\Exception $e) {
......@@ -106,8 +108,8 @@ class AddAdImages extends DirectRequest
$this->setParams([
'AdImages' => $this->goalAdImages->map(function (GoalAdImage $goalAdImage) {
return [
'Name' => base64_encode($goalAdImage->adImage->imageData),
'ImageData' => $goalAdImage->adImage->imageData,
'Name' => $goalAdImage->adImage->name,
'ImageData' => base64_encode($goalAdImage->adImage->imageData),
];
})->toArray(),
]);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!