Commit 7e55342f by Vladislav

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

1 parent 9049cf37
......@@ -78,6 +78,7 @@ class AdvertisementsAdd extends Command
});
})
->whereNull('advertisements.deleted_at')
->whereNull('goal_advertisements.deleted_at')
->whereNull('goal_advertisements.external_id')
->whereNull('goal_advertisements.reserve_create_at')
->whereNotNull('goal_advertisements.goal_ad_group_external_id')
......
......@@ -79,7 +79,10 @@ class AdvertisementsUpdate extends Command
});
})
->whereNotNull('goal_advertisements.external_id')
->whereNull('goal_advertisements.deleted_need')
->whereNull('advertisements.deleted_at')
->whereNull('goal_advertisements.archived_need')
->whereNull('goal_advertisements.archive_at')
->whereNull('goal_advertisements.reserve_update_at')
->whereNotNull('goal_advertisements.updated_need')
->whereNotNull('goal_advertisements.goal_ad_group_external_id')
......
......@@ -75,10 +75,10 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$schedule->command(DictionaryCampaignsSyncByCampaign::class)->everyThirtyMinutes();
$schedule->command(RefreshLimits::class)->hourly();
$schedule->command(DictionaryCampaignsSyncByCampaign::class)->everyThirtyMinutes();
if (Redis::get('cron_sync_disable')) {
return;
}
......
......@@ -7,8 +7,10 @@ use App\Models\Campaigns;
use App\Models\Dictionary;
use App\Models\Pivots\DictionaryCampaign;
use App\Models\Tokens;
use App\Models\Variable;
use App\Service\API\API;
use App\Service\Requests\APIRequest;
use App\Service\StrReplaceByVariables;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
......@@ -46,6 +48,11 @@ class TokensController extends Controller
{
$token->loadCount('errors');
$mainToken = Tokens::where('type', Tokens::MAIN)->first();
$variables = Variable::all();
$lists = [];
return Inertia::render('Tokens/Edit', [
'token' => [
'id' => $token->getKey(),
......@@ -62,7 +69,23 @@ class TokensController extends Controller
),
'cities' => (
!$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
public function failed()
{
try {
$this->api->failed();
} catch (\Exception $e) {
$this->failed();
}
}
}
......@@ -97,6 +97,7 @@ class GoalAdvertisement extends Pivot
];
public $incrementing = true;
public $timestamps = false;
static public function getWithPivot()
{
......@@ -221,7 +222,10 @@ class GoalAdvertisement extends Pivot
*/
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')
->orWhere(function (Builder $query) {
return $query->whereExists(function (\Illuminate\Database\Query\Builder $query) {
......@@ -240,9 +244,7 @@ class GoalAdvertisement extends Pivot
->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
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();
} 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();
if ($model) {
......@@ -75,6 +75,18 @@ class UpdateCampaigns extends DirectRequest
$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 {
Log::debug("UpdateCampaigns, empty Id, token_id {$this->getToken()->getKey()}");
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!