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 dd3d24f1
authored
Jun 28, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19500 Синхронизация модификаторов
1 parent
80c9a8df
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
26 additions
and
87 deletions
app/Console/Commands/BidModifiersAdd.php
app/Console/Commands/DictionaryCampaignsSyncByCampaign.php
app/Jobs/ProcessCallLimitedAPI.php
app/Service/Requests/Direct/AddAdGroups.php
app/Service/Requests/Direct/AddAds.php
app/Service/Requests/Direct/AddBidModifiers.php
app/Service/Requests/Direct/AddCampaigns.php
app/Service/Requests/Direct/AddKeywords.php
app/Service/Requests/Direct/DeleteKeywords.php
app/Service/Requests/Direct/UpdateAdGroups.php
app/Service/Requests/Direct/UpdateAds.php
app/Service/Requests/Direct/UpdateCampaigns.php
app/Service/Requests/Direct/UpdateKeywords.php
app/Console/Commands/BidModifiersAdd.php
View file @
dd3d24f
...
...
@@ -57,6 +57,7 @@ class BidModifiersAdd extends Command
->
join
(
'bid_modifiers'
,
'goal_bid_modifiers.bid_modifier_id'
,
'='
,
'bid_modifiers.id'
)
->
whereNull
(
'bid_modifiers.deleted_at'
)
->
whereNull
(
'goal_bid_modifiers.external_id'
)
->
whereNotNull
(
'goal_bid_modifiers.dictionary_campaign_external_id'
)
->
where
(
function
(
Builder
$query
)
{
$query
->
whereNull
(
'goal_bid_modifiers.goal_ad_group_id'
)
->
orWhere
(
function
(
Builder
$query
)
{
...
...
@@ -64,22 +65,15 @@ class BidModifiersAdd extends Command
->
whereNotNull
(
'goal_bid_modifiers.goal_ad_group_external_id'
);
});
})
->
whereNotNull
(
'goal_bid_modifiers.dictionary_campaign_external_id'
)
->
whereIn
(
'goal_bid_modifiers.dictionary_campaign_id'
,
$token
->
dictionaryCampaignsEnabledForExternalSynchronized
->
pluck
(
'id'
))
->
select
([
'goal_bid_modifiers.id as id'
,
'goal_bid_modifiers.dictionary_campaign_external_id as dictionary_campaign_external_id'
,
'goal_bid_modifiers.goal_ad_group_external_id as goal_ad_group_external_id'
,
'bid_modifiers.mobile_adjustment as mobile_adjustment'
,
'bid_modifiers.desktop_adjustment as desktop_adjustment'
,
DB
::
raw
(
'json_arrayagg(bid_modifiers.id) as ids'
),
DB
::
raw
(
'json_arrayagg(bid_modifiers.demographics_adjustment) as demographics_adjustments'
),
DB
::
raw
(
'json_arrayagg(bid_modifiers.retargeting_adjustment) as retargeting_adjustments'
),
])
->
groupBy
([
'goal_bid_modifiers.dictionary_campaign_external_id'
,
'goal_bid_modifiers.goal_ad_group_external_id'
,
'bid_modifiers.mobile_adjustment'
,
'bid_modifiers.desktop_adjustment'
,
'bid_modifiers.demographics_adjustment as demographics_adjustment'
,
'bid_modifiers.retargeting_adjustment as retargeting_adjustment'
,
])
->
get
();
...
...
app/Console/Commands/DictionaryCampaignsSyncByCampaign.php
View file @
dd3d24f
...
...
@@ -154,7 +154,7 @@ class DictionaryCampaignsSyncByCampaign extends Command
INNER JOIN dictionary_campaigns dc on dc.campaign_id = c.id
LEFT JOIN ad_groups ag on c.id = ag.campaign_id AND bm.ad_group_id = ag.id
LEFT JOIN goal_ad_groups gag on dc.dictionary_id = gag.dictionary_campaign_id AND ag.id = gag.ad_group_id
LEFT JOIN goal_bid_modifiers gbm on bm.id = gbm.bid_modifier_id
LEFT JOIN goal_bid_modifiers gbm on bm.id = gbm.bid_modifier_id
and gbm.dictionary_campaign_id = dc.id
WHERE gbm.bid_modifier_id is null
"
);
...
...
app/Jobs/ProcessCallLimitedAPI.php
View file @
dd3d24f
...
...
@@ -51,18 +51,19 @@ class ProcessCallLimitedAPI implements ShouldQueue//, ShouldBeUnique
try
{
//резервируем на это количетсво
$limitId
=
$limits
->
doRezerv
(
$this
->
api
,
$objects
);
//вызываем очередь получения данных от АПИ
//туда передаем сохраненный лимит
//там уже либо будет удален, если не удастся выполнить запрос
//либо обновятся данные
dispatch
(
new
ProcessCallAPI
(
$limitId
,
$this
->
api
))
->
onQueue
(
'api'
);
}
catch
(
\Exception
$e
){
//нет свободных баллов, замораживаем до следующего часа
Log
::
debug
(
$e
);
$this
->
reRunHour
();
return
;
}
//вызываем очередь получения данных от АПИ
//туда передаем сохраненный лимит
//там уже либо будет удален, если не удастся выполнить запрос
//либо обновятся данные
dispatch
(
new
ProcessCallAPI
(
$limitId
,
$this
->
api
))
->
onQueue
(
'api'
);
}
// /**
...
...
@@ -78,6 +79,7 @@ class ProcessCallLimitedAPI implements ShouldQueue//, ShouldBeUnique
private
function
reRunHour
(){
$process
=
new
ProcessCallLimitedAPI
(
$this
->
api
);
dispatch
(
$process
)
->
delay
(
now
()
->
addMinutes
(
60
-
date
(
"i"
)));
->
delay
(
now
()
->
addMinutes
(
60
-
date
(
"i"
)))
->
onQueue
(
'limits'
);
}
}
app/Service/Requests/Direct/AddAdGroups.php
View file @
dd3d24f
...
...
@@ -50,11 +50,6 @@ class AddAdGroups extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
}
if
(
!
isset
(
$response
[
'result'
][
'AddResults'
]))
{
return
;
}
...
...
app/Service/Requests/Direct/AddAds.php
View file @
dd3d24f
...
...
@@ -51,11 +51,6 @@ class AddAds extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
}
if
(
!
isset
(
$response
[
'result'
][
'AddResults'
]))
{
return
;
}
...
...
app/Service/Requests/Direct/AddBidModifiers.php
View file @
dd3d24f
...
...
@@ -49,11 +49,7 @@ class AddBidModifiers extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
}
Log
::
debug
(
$response
);
if
(
!
isset
(
$response
[
'result'
][
'AddResults'
]))
{
return
;
}
...
...
@@ -68,10 +64,10 @@ class AddBidModifiers extends DirectRequest
$external_id
=
(
string
)
$add_result
[
'Id'
];
/* @var $goal
Ad
\stdClass */
$goal
Ad
=
$this
->
goalBidModifiers
->
get
(
$key
);
/* @var $goal
BidModifier
\stdClass */
$goal
BidModifier
=
$this
->
goalBidModifiers
->
get
(
$key
);
GoalBidModifier
::
where
In
(
'id'
,
$goalAd
->
ids
)
GoalBidModifier
::
where
(
'id'
,
$goalBidModifier
->
id
)
->
update
([
'external_id'
=>
$external_id
,
'external_upload_at'
=>
Carbon
::
now
(),
...
...
@@ -117,7 +113,7 @@ class AddBidModifiers extends DirectRequest
$data
[
'DesktopAdjustment'
]
=
$desktop_adjustment
;
}
elseif
(
$demographics_adjustment
s
=
array_map
(
function
(
$demographics_adjustment
)
{
}
elseif
(
$demographics_adjustment
=
@
json_decode
(
$goalBidModifier
->
demographics_adjustment
,
true
)
)
{
unset
(
$demographics_adjustment
[
'Enabled'
]);
...
...
@@ -128,24 +124,18 @@ class AddBidModifiers extends DirectRequest
unset
(
$demographics_adjustment
[
'Age'
]);
}
return
$demographics_adjustment
;
},
array_filter
(
@
json_decode
(
$goalBidModifier
->
demographics_adjustments
,
true
))))
{
$data
[
'DemographicsAdjustments'
]
=
$demographics_adjustments
;
$data
[
'DemographicsAdjustments'
]
=
[
$demographics_adjustment
];
}
elseif
(
$retargeting_adjustment
s
=
array_map
(
function
(
$retargeting_adjustment
)
{
}
elseif
(
$retargeting_adjustment
=
@
json_decode
(
$goalBidModifier
->
retargeting_adjustment
,
true
)
)
{
unset
(
$retargeting_adjustment
[
'Accessible'
]);
unset
(
$retargeting_adjustment
[
'Enabled'
]);
return
$retargeting_adjustment
;
},
array_filter
(
@
json_decode
(
$goalBidModifier
->
retargeting_adjustments
,
true
))))
{
$data
[
'RetargetingAdjustments'
]
=
$retargeting_adjustments
;
$data
[
'RetargetingAdjustments'
]
=
[
$retargeting_adjustment
];
}
return
$data
;
...
...
app/Service/Requests/Direct/AddCampaigns.php
View file @
dd3d24f
...
...
@@ -52,11 +52,6 @@ class AddCampaigns extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
}
if
(
!
isset
(
$response
[
'result'
][
'AddResults'
]))
{
return
;
}
...
...
app/Service/Requests/Direct/AddKeywords.php
View file @
dd3d24f
...
...
@@ -51,12 +51,6 @@ class AddKeywords extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
}
if
(
!
isset
(
$response
[
'result'
][
'AddResults'
]))
{
return
;
}
...
...
app/Service/Requests/Direct/DeleteKeywords.php
View file @
dd3d24f
...
...
@@ -42,11 +42,6 @@ class DeleteKeywords extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
}
if
(
!
isset
(
$response
[
'result'
][
'DeleteResults'
]))
{
return
;
}
...
...
app/Service/Requests/Direct/UpdateAdGroups.php
View file @
dd3d24f
...
...
@@ -40,11 +40,6 @@ class UpdateAdGroups extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
}
if
(
!
isset
(
$response
[
'result'
][
'UpdateResults'
]))
{
return
;
}
...
...
app/Service/Requests/Direct/UpdateAds.php
View file @
dd3d24f
...
...
@@ -37,12 +37,6 @@ class UpdateAds extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
}
if
(
!
isset
(
$response
[
'result'
][
'UpdateResults'
]))
{
return
;
}
...
...
app/Service/Requests/Direct/UpdateCampaigns.php
View file @
dd3d24f
...
...
@@ -39,11 +39,6 @@ class UpdateCampaigns extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
}
if
(
!
isset
(
$response
[
'result'
][
'UpdateResults'
]))
{
return
;
}
...
...
app/Service/Requests/Direct/UpdateKeywords.php
View file @
dd3d24f
...
...
@@ -38,11 +38,6 @@ class UpdateKeywords extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
}
if
(
!
isset
(
$response
[
'result'
][
'UpdateResults'
]))
{
return
;
}
...
...
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