Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit aa26b6b9
authored
Jul 09, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#20434 Загрузка и синхронизация sitelinks
1 parent
7ddeb34a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
app/Console/Commands/DictionaryCampaignsSyncByCampaign.php
app/Console/Commands/SitelinksLoad.php
app/Console/Commands/VCardsLoad.php
app/Console/Commands/DictionaryCampaignsSyncByCampaign.php
View file @
aa26b6b
...
...
@@ -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))
"
);
//грузим связь объявлений к расширения которых по какой то причне нет в целевых.
...
...
app/Console/Commands/SitelinksLoad.php
View file @
aa26b6b
...
...
@@ -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
;
}
...
...
app/Console/Commands/VCardsLoad.php
View file @
aa26b6b
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment