Commit 7e55342f by Vladislav

#22080 Физически удалены РК с целевых токенах

1 parent 9049cf37
...@@ -78,6 +78,7 @@ class AdvertisementsAdd extends Command ...@@ -78,6 +78,7 @@ class AdvertisementsAdd extends Command
}); });
}) })
->whereNull('advertisements.deleted_at') ->whereNull('advertisements.deleted_at')
->whereNull('goal_advertisements.deleted_at')
->whereNull('goal_advertisements.external_id') ->whereNull('goal_advertisements.external_id')
->whereNull('goal_advertisements.reserve_create_at') ->whereNull('goal_advertisements.reserve_create_at')
->whereNotNull('goal_advertisements.goal_ad_group_external_id') ->whereNotNull('goal_advertisements.goal_ad_group_external_id')
......
...@@ -79,7 +79,10 @@ class AdvertisementsUpdate extends Command ...@@ -79,7 +79,10 @@ class AdvertisementsUpdate extends Command
}); });
}) })
->whereNotNull('goal_advertisements.external_id') ->whereNotNull('goal_advertisements.external_id')
->whereNull('goal_advertisements.deleted_need')
->whereNull('advertisements.deleted_at') ->whereNull('advertisements.deleted_at')
->whereNull('goal_advertisements.archived_need')
->whereNull('goal_advertisements.archive_at')
->whereNull('goal_advertisements.reserve_update_at') ->whereNull('goal_advertisements.reserve_update_at')
->whereNotNull('goal_advertisements.updated_need') ->whereNotNull('goal_advertisements.updated_need')
->whereNotNull('goal_advertisements.goal_ad_group_external_id') ->whereNotNull('goal_advertisements.goal_ad_group_external_id')
......
...@@ -75,10 +75,10 @@ class Kernel extends ConsoleKernel ...@@ -75,10 +75,10 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)
{ {
$schedule->command(DictionaryCampaignsSyncByCampaign::class)->everyThirtyMinutes();
$schedule->command(RefreshLimits::class)->hourly(); $schedule->command(RefreshLimits::class)->hourly();
$schedule->command(DictionaryCampaignsSyncByCampaign::class)->everyThirtyMinutes();
if (Redis::get('cron_sync_disable')) { if (Redis::get('cron_sync_disable')) {
return; return;
} }
......
...@@ -7,8 +7,10 @@ use App\Models\Campaigns; ...@@ -7,8 +7,10 @@ use App\Models\Campaigns;
use App\Models\Dictionary; use App\Models\Dictionary;
use App\Models\Pivots\DictionaryCampaign; use App\Models\Pivots\DictionaryCampaign;
use App\Models\Tokens; use App\Models\Tokens;
use App\Models\Variable;
use App\Service\API\API; use App\Service\API\API;
use App\Service\Requests\APIRequest; use App\Service\Requests\APIRequest;
use App\Service\StrReplaceByVariables;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
...@@ -46,6 +48,11 @@ class TokensController extends Controller ...@@ -46,6 +48,11 @@ class TokensController extends Controller
{ {
$token->loadCount('errors'); $token->loadCount('errors');
$mainToken = Tokens::where('type', Tokens::MAIN)->first(); $mainToken = Tokens::where('type', Tokens::MAIN)->first();
$variables = Variable::all();
$lists = [];
return Inertia::render('Tokens/Edit', [ return Inertia::render('Tokens/Edit', [
'token' => [ 'token' => [
'id' => $token->getKey(), 'id' => $token->getKey(),
...@@ -62,7 +69,23 @@ class TokensController extends Controller ...@@ -62,7 +69,23 @@ class TokensController extends Controller
), ),
'cities' => ( 'cities' => (
!$token->isMain() !$token->isMain()
? $token->load('cities.dictionaryCampaigns')->cities ? $token->load('cities.dictionaryCampaigns')->cities->transform(function ($city) use ($variables, &$lists) {
$city->dictionaryCampaigns->transform(function ($dictionaryCampaign) use ($variables, &$lists) {
if (!isset($lists[$dictionaryCampaign->getKey()])) {
$list = Variable::getListVariablesByDictionaryCampaign($dictionaryCampaign->getKey(), $variables);
$lists[$dictionaryCampaign->getKey()] = $list;
} else {
$list = $lists[$dictionaryCampaign->getKey()];
}
$dictionaryCampaign->name = StrReplaceByVariables::getInstance($dictionaryCampaign->name, $list)->get();
return $dictionaryCampaign;
});
return $city;
})
: [] : []
), ),
], ],
......
...@@ -96,7 +96,11 @@ class ProcessCallAPI implements ShouldQueue ...@@ -96,7 +96,11 @@ class ProcessCallAPI implements ShouldQueue
public function failed() public function failed()
{ {
try {
$this->api->failed(); $this->api->failed();
} catch (\Exception $e) {
$this->failed();
}
} }
} }
...@@ -97,6 +97,7 @@ class GoalAdvertisement extends Pivot ...@@ -97,6 +97,7 @@ class GoalAdvertisement extends Pivot
]; ];
public $incrementing = true; public $incrementing = true;
public $timestamps = false;
static public function getWithPivot() static public function getWithPivot()
{ {
...@@ -221,7 +222,10 @@ class GoalAdvertisement extends Pivot ...@@ -221,7 +222,10 @@ class GoalAdvertisement extends Pivot
*/ */
public function scopeNeedDeleted($query) public function scopeNeedDeleted($query)
{ {
return $query->where(function (Builder $query) { return $query->whereNull('goal_advertisements.deleted_at')
->whereNull('goal_advertisements.archive_at')
->whereNull('goal_advertisements.archived_need')
->where(function (Builder $query) {
return $query->whereNotNull('deleted_need') return $query->whereNotNull('deleted_need')
->orWhere(function (Builder $query) { ->orWhere(function (Builder $query) {
return $query->whereExists(function (\Illuminate\Database\Query\Builder $query) { return $query->whereExists(function (\Illuminate\Database\Query\Builder $query) {
...@@ -240,9 +244,7 @@ class GoalAdvertisement extends Pivot ...@@ -240,9 +244,7 @@ class GoalAdvertisement extends Pivot
->whereColumn('goal_advertisements.goal_ad_group_id', 'goal_ad_groups.id'); ->whereColumn('goal_advertisements.goal_ad_group_id', 'goal_ad_groups.id');
}); });
}); });
})->whereNull('goal_advertisements.deleted_at') });
->whereNull('goal_advertisements.archive_at')
->whereNull('goal_advertisements.archived_need');
} }
/** /**
......
...@@ -64,7 +64,7 @@ class UpdateCampaigns extends DirectRequest ...@@ -64,7 +64,7 @@ class UpdateCampaigns extends DirectRequest
if (isset($update_result['Errors'][0]['Details']) && $update_result['Errors'][0]['Details'] === 'It is forbidden to change an archived campaign') { if (isset($update_result['Errors'][0]['Details']) && $update_result['Errors'][0]['Details'] === 'It is forbidden to change an archived campaign') {
DictionaryCampaign::whereExternalId($external_id)->delete(); DictionaryCampaign::whereExternalId($external_id)->delete();
} elseif (isset($update_result['Message']) && $update_result['Message'] === 'Object not found') { } /*elseif (isset($update_result['Message']) && $update_result['Message'] === 'Object not found') {
$model = GoalAdGroup::whereExternalId($external_id)->first(); $model = GoalAdGroup::whereExternalId($external_id)->first();
if ($model) { if ($model) {
...@@ -75,6 +75,18 @@ class UpdateCampaigns extends DirectRequest ...@@ -75,6 +75,18 @@ class UpdateCampaigns extends DirectRequest
$model->delete(); $model->delete();
} }
}*/ elseif (isset($update_result['Errors']) && count($update_result['Errors'])) {
$model = DictionaryCampaign::whereExternalId($external_id)->first();
if ($model) {
$model->errors()->create([
'token_id' => $this->getToken()->getKey(),
'service' => $this->getService(),
'method' => $this->getMethod(),
'params' => $data,
'errors' => $update_result['Errors'],
]);
}
} else { } else {
Log::debug("UpdateCampaigns, empty Id, token_id {$this->getToken()->getKey()}"); Log::debug("UpdateCampaigns, empty Id, token_id {$this->getToken()->getKey()}");
Log::debug($update_result); Log::debug($update_result);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!