Commit aa26b6b9 by Vladislav

#20434 Загрузка и синхронизация sitelinks

1 parent 7ddeb34a
......@@ -204,6 +204,8 @@ class DictionaryCampaignsSyncByCampaign extends Command
LEFT JOIN sitelinks s on ad.sitelink_external_id = s.external_id
LEFT JOIN goal_sitelinks gs on s.id = gs.sitelink_id and gs.token_id = d.token_id
WHERE gad.advertisement_id is null and ad.campaign_id is not null
and (ad.sitelink_external_id is null or (ad.sitelink_external_id is not null and s.id is not null))
and (ad.v_card_external_id is null or (ad.v_card_external_id is not null and vc.id is not null))
");
//грузим связь объявлений к расширения которых по какой то причне нет в целевых.
......
......@@ -2,9 +2,11 @@
namespace App\Console\Commands;
use App\Models\Advertisement;
use App\Models\Tokens;
use App\Service\Requests\Direct\GetSitelinks;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SitelinksLoad extends Command
{
......@@ -46,9 +48,27 @@ class SitelinksLoad extends Command
throw new \Exception('Не найден токен блин');
}
$sitelink_external_ids = DB::table('advertisements')
->leftJoin('sitelinks', 'sitelinks.external_id', '=', 'advertisements.sitelink_external_id')
->whereNotNull('advertisements.sitelink_external_id')
->whereNull('sitelinks.id')
->groupBy('advertisements.sitelink_external_id')
->pluck('advertisements.sitelink_external_id');
if (!$sitelink_external_ids->count()) {
return 0;
}
$sitelink_external_ids = DB::table(Advertisement::getModel()->getTable())
->whereNotNull('sitelink_external_id')
->groupBy('sitelink_external_id')
->pluck('sitelink_external_id');
$request = new GetSitelinks();
$request->setToken($token)
->call();
->call([
'Ids' => $sitelink_external_ids->toArray(),
]);
return 0;
}
......
......@@ -5,6 +5,7 @@ namespace App\Console\Commands;
use App\Models\Tokens;
use App\Service\Requests\Direct\GetVCards;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class VCardsLoad extends Command
{
......@@ -46,9 +47,22 @@ class VCardsLoad extends Command
throw new \Exception('Не найден токен блин');
}
$v_card_external_ids = DB::table('advertisements')
->leftJoin('v_cards', 'v_cards.external_id', '=', 'advertisements.v_card_external_id')
->whereNotNull('advertisements.v_card_external_id')
->whereNull('v_cards.id')
->groupBy('advertisements.v_card_external_id')
->pluck('advertisements.v_card_external_id');
if (!$v_card_external_ids->count()) {
return 0;
}
$request = new GetVCards();
$request->setToken($token)
->call();
->call([
'Ids' => $v_card_external_ids->toArray(),
]);
return 0;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!