Commit 41f8490a by Vladislav

Оптимизация удаление визиток

1 parent e7bcf03d
......@@ -58,14 +58,14 @@ class VCardsDelete extends Command
return 0;
}
private function sendRequest($token, $ads)
private function sendRequest($token, $vCards)
{
/* @var $ads VCard[]|GoalVCard[] */
if (!$ads->count()) {
/* @var $vCards VCard[]|GoalVCard[] */
if (!$vCards->count()) {
return;
}
foreach (array_chunk($ads->pluck('external_id')->toArray(), 1000) as $items) {
foreach (array_chunk($vCards->pluck('external_id')->toArray(), 1000) as $items) {
if ($token->isMain()) {
VCard::whereIn('external_id', $items)
->update([
......@@ -79,10 +79,12 @@ class VCardsDelete extends Command
}
}
exit();
$request = new DeleteVCards();
$request->setToken($token)
->call([
'ids' => $ads->pluck('external_id')->toArray(),
'ids' => $vCards->pluck('external_id')->toArray(),
]);
}
......
......@@ -69,7 +69,6 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
return;
$schedule->command(DictionaryCampaignsSyncByCampaign::class)->everyThirtyMinutes();
......
......@@ -540,7 +540,7 @@ class DictionaryCampaign extends Pivot
$query->whereNotNull('goal_advertisements.archive_at')
->orWhereNotNull('goal_advertisements.deleted_at')
->orWhereNull('goal_advertisements.id');
})->forExternal()->forNotReserveDelete();
})->forExternal()->forNotReserveDelete()->select('goal_v_cards.*');
}
public function goalAudienceTargets()
......
......@@ -29,7 +29,7 @@ class DeleteVCards extends DirectRequest
public function slice($maxObjects): ?APIRequest
{
return $this->sliceByKey($maxObjects, ['SelectionCriteria', 'Ids']);;
return $this->sliceByKey($maxObjects, ['SelectionCriteria', 'Ids']);
}
public function handle($response)
......@@ -117,7 +117,7 @@ class DeleteVCards extends DirectRequest
'reserve_delete_at' => null,
]);
} else {
VCard::whereIn('external_id', $this->getParams()['SelectionCriteria']['Ids'])
GoalVCard::whereIn('external_id', $this->getParams()['SelectionCriteria']['Ids'])
->update([
'reserve_delete_at' => null,
]);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!