Commit 68f31b2a by Vladislav

#19496 Запрос измененных объявлений

1 parent 27516d79
...@@ -67,6 +67,13 @@ class AdvertisementsAdd extends Command ...@@ -67,6 +67,13 @@ class AdvertisementsAdd extends Command
->whereNull('goal_ad_extensions.external_id') ->whereNull('goal_ad_extensions.external_id')
->whereColumn('goal_advertisements.id', 'goal_advertisement_goal_ad_extensions.goal_advertisement_id'); ->whereColumn('goal_advertisements.id', 'goal_advertisement_goal_ad_extensions.goal_advertisement_id');
}) })
->where(function (Builder $query) {
$query->whereNull('goal_advertisements.goal_v_card_id')
->orWhere(function (Builder $query) {
$query->whereNotNull('goal_advertisements.goal_v_card_id')
->whereNotNull('goal_advertisements.goal_v_card_external_id');
});
})
->whereNull('advertisements.deleted_at') ->whereNull('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')
...@@ -83,7 +90,7 @@ class AdvertisementsAdd extends Command ...@@ -83,7 +90,7 @@ class AdvertisementsAdd extends Command
'advertisements.title2 as title2', 'advertisements.title2 as title2',
'advertisements.href as href', 'advertisements.href as href',
'advertisements.display_url_path as display_url_path', 'advertisements.display_url_path as display_url_path',
'advertisements.v_card_external_id as v_card_external_id', 'goal_advertisements.goal_v_card_external_id as goal_v_card_external_id',
'advertisements.ad_image_hash as ad_image_hash', 'advertisements.ad_image_hash as ad_image_hash',
'advertisements.site_link_set_id as site_link_set_id', 'advertisements.site_link_set_id as site_link_set_id',
DB::raw('JSON_ARRAYAGG(goal_ad_extensions.external_id) as ad_extension_ids'), DB::raw('JSON_ARRAYAGG(goal_ad_extensions.external_id) as ad_extension_ids'),
...@@ -97,6 +104,10 @@ class AdvertisementsAdd extends Command ...@@ -97,6 +104,10 @@ class AdvertisementsAdd extends Command
->groupBy('goal_advertisements.id') ->groupBy('goal_advertisements.id')
->get(); ->get();
if (!$goalAds->count()) {
continue;
}
foreach (array_chunk($goalAds->pluck('id')->toArray(), 1000) as $items) { foreach (array_chunk($goalAds->pluck('id')->toArray(), 1000) as $items) {
GoalAdvertisement::whereIn('id', $items) GoalAdvertisement::whereIn('id', $items)
->update([ ->update([
......
...@@ -73,7 +73,7 @@ class AdvertisementsUpdate extends Command ...@@ -73,7 +73,7 @@ class AdvertisementsUpdate extends Command
'advertisements.title2 as title2', 'advertisements.title2 as title2',
'advertisements.href as href', 'advertisements.href as href',
'advertisements.display_url_path as display_url_path', 'advertisements.display_url_path as display_url_path',
'advertisements.v_card_external_id as v_card_external_id', 'goal_advertisements.goal_v_card_external_id as goal_v_card_external_id',
'advertisements.ad_image_hash as ad_image_hash', 'advertisements.ad_image_hash as ad_image_hash',
'advertisements.site_link_set_id as site_link_set_id', 'advertisements.site_link_set_id as site_link_set_id',
DB::raw("JSON_OBJECTAGG('AdExtensionId', goal_ad_extensions.external_id, 'Operation', 'SET') as ad_extensions"), DB::raw("JSON_OBJECTAGG('AdExtensionId', goal_ad_extensions.external_id, 'Operation', 'SET') as ad_extensions"),
......
...@@ -147,7 +147,7 @@ class AddAds extends DirectRequest ...@@ -147,7 +147,7 @@ class AddAds extends DirectRequest
} }
if ($goalAdvertisement->v_card_external_id) { if ($goalAdvertisement->v_card_external_id) {
$data['TextAd']['VCardId'] = $goalAdvertisement->v_card_external_id; $data['TextAd']['VCardId'] = $goalAdvertisement->goal_v_card_external_id;
} }
if ($goalAdvertisement->ad_image_hash) { if ($goalAdvertisement->ad_image_hash) {
......
...@@ -130,8 +130,8 @@ class UpdateAds extends DirectRequest ...@@ -130,8 +130,8 @@ class UpdateAds extends DirectRequest
$data['TextAd']['DisplayUrlPath'] = StrReplaceByVariables::getInstance($goalAdvertisement->display_url_path, $list)->get(); $data['TextAd']['DisplayUrlPath'] = StrReplaceByVariables::getInstance($goalAdvertisement->display_url_path, $list)->get();
} }
if ($goalAdvertisement->v_card_external_id) { if ($goalAdvertisement->goal_v_card_external_id) {
$data['TextAd']['VCardId'] = $goalAdvertisement->v_card_external_id; $data['TextAd']['VCardId'] = $goalAdvertisement->goal_v_card_external_id;
} }
if ($goalAdvertisement->ad_image_hash) { if ($goalAdvertisement->ad_image_hash) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!