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 ff2fdde6
authored
Jun 10, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19473 Получение кеша фраз
1 parent
194df9a4
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
49 additions
and
31 deletions
app/Console/Commands/AdGroupsLoadKeywords.php
app/Console/Commands/AdGroupsLoadUpdated.php
app/Console/Commands/AdGroupsUpdate.php
app/Console/Commands/CampaignsCheckUpdatedChildrenAdGroups.php
app/Console/Commands/CampaignsFirstLoad.php
app/Console/Commands/CampaignsLoadGroups.php
app/Console/Commands/CampaignsLoadUpdated.php
app/Http/Controllers/TokensController.php
app/Service/Requests/Direct/GetKeywords.php
app/Service/Requests/Direct/UpdateAdGroups.php
database/migrations/2021_06_02_10638_create_goal_ad_groups_table.php
app/Console/Commands/AdGroupsLoadKeywords.php
View file @
ff2fdde
...
...
@@ -15,7 +15,7 @@ class AdGroupsLoadKeywords extends Command
*
* @var string
*/
protected
$signature
=
'ad
G
roups:loadKeywords'
;
protected
$signature
=
'ad
g
roups:loadKeywords'
;
/**
* The console command description.
...
...
app/Console/Commands/AdGroupsLoadUpdated.php
View file @
ff2fdde
...
...
@@ -42,9 +42,8 @@ class AdGroupsLoadUpdated extends Command
public
function
handle
()
{
$adGroups
=
AdGroup
::
has
(
'campaignForEnabledForManaged'
)
->
forUpdatedSelf
()
->
get
();
if
(
!
$adGroups
->
count
())
{
return
;
}
if
(
$adGroups
->
count
())
{
$token
=
Tokens
::
where
(
'type'
,
Tokens
::
MAIN
)
->
first
();
if
(
!
$token
)
{
...
...
@@ -67,6 +66,8 @@ class AdGroupsLoadUpdated extends Command
'AdGroupIds'
=>
$ids
,
]);
}
$tokens
=
Tokens
::
has
(
'dictionaryCampaignsEnabledForExternalSynchronized.groupsForExternalForUpdatedSelf'
)
->
with
(
'dictionaryCampaignsEnabledForExternalSynchronized.groupsForExternalForUpdatedSelf'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
...
...
app/Console/Commands/AdGroupsUpdate.php
View file @
ff2fdde
...
...
@@ -53,7 +53,7 @@ class AdGroupsUpdate extends Command
$factory
->
setToken
(
$token
);
$factory
->
getRequest
(
'AdGroup'
,
'update'
)
$factory
->
getRequest
(
'AdGroup
s
'
,
'update'
)
->
call
([
'goalAdGroups'
=>
$token
->
dictionaryCampaignsEnabledForExternalUpdated
->
pluck
(
'groupsForExternalForNeedUpdated'
)
->
collapse
(),
...
...
app/Console/Commands/CampaignsCheckUpdatedChildrenAdGroups.php
View file @
ff2fdde
...
...
@@ -41,9 +41,7 @@ class CampaignsCheckUpdatedChildrenAdGroups extends Command
*/
public
function
handle
()
{
if
(
!
Campaigns
::
forUpdatedChildren
()
->
exists
())
{
return
;
}
if
(
Campaigns
::
forUpdatedChildren
()
->
exists
())
{
$token
=
Tokens
::
where
(
'type'
,
Tokens
::
MAIN
)
->
first
();
if
(
!
$token
)
{
...
...
@@ -61,6 +59,8 @@ class CampaignsCheckUpdatedChildrenAdGroups extends Command
'Timestamp'
=>
$token
->
check_changes_ad_group_at
->
toIso8601ZuluString
(),
]);
}
$tokens
=
Tokens
::
has
(
'dictionaryCampaignsEnabledForExternalSynchronizedUpdatedChildren'
)
->
with
(
'dictionaryCampaignsEnabledForExternalSynchronizedUpdatedChildren'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
...
...
app/Console/Commands/CampaignsFirstLoad.php
View file @
ff2fdde
...
...
@@ -6,6 +6,7 @@ use App\Models\Tokens;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\Artisan
;
class
CampaignsFirstLoad
extends
Command
{
...
...
@@ -48,8 +49,10 @@ class CampaignsFirstLoad extends Command
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
getRequest
(
'Changes'
,
'CheckDictionaries'
)
->
call
();
$factory
->
getRequest
(
'Campaigns'
,
'get'
)
->
call
();
Artisan
::
call
(
DictionariesLoad
::
class
);
Artisan
::
call
(
CampaignsLoadGroups
::
class
);
Artisan
::
call
(
AdGroupsLoadKeywords
::
class
);
return
0
;
}
...
...
app/Console/Commands/CampaignsLoadGroups.php
View file @
ff2fdde
...
...
@@ -63,15 +63,6 @@ class CampaignsLoadGroups extends Command
'CampaignIds'
=>
$campaign_ids
,
]);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
getRequest
(
'Keywords'
,
'get'
)
->
call
([
'CampaignIds'
=>
$campaign_ids
,
]);
return
0
;
}
}
app/Console/Commands/CampaignsLoadUpdated.php
View file @
ff2fdde
...
...
@@ -44,9 +44,8 @@ class CampaignsLoadUpdated extends Command
public
function
handle
()
{
$campaigns
=
Campaigns
::
forEnabled
()
->
forUpdatedSelf
()
->
get
();
if
(
!
$campaigns
->
count
())
{
return
;
}
if
(
$campaigns
->
count
())
{
$token
=
Tokens
::
where
(
'type'
,
Tokens
::
MAIN
)
->
first
();
if
(
!
$token
)
{
...
...
@@ -60,6 +59,8 @@ class CampaignsLoadUpdated extends Command
'ids'
=>
$campaigns
->
pluck
(
'external_id'
)
->
all
(),
]);
}
$tokens
=
Tokens
::
has
(
'dictionaryCampaignsEnabledForExternalSynchronizedUpdatedSelf'
)
->
with
(
'dictionaryCampaignsEnabledForExternalSynchronizedUpdatedSelf'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
...
...
app/Http/Controllers/TokensController.php
View file @
ff2fdde
...
...
@@ -97,9 +97,18 @@ class TokensController extends Controller
return
Redirect
::
back
();
}
$
campaign
->
update
(
[
$
data
=
[
'manage'
=>
!!
request
(
'managed'
),
];
if
(
$data
[
'manage'
])
{
$data
[
'groups_loaded_at'
]
=
null
;
$campaign
->
groups
()
->
update
([
'keywords_loaded_at'
=>
null
,
]);
}
$campaign
->
update
(
$data
);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign '
.
(
$campaign
->
manage
?
'added'
:
'deleted'
)
.
'.'
);
}
...
...
@@ -116,14 +125,21 @@ class TokensController extends Controller
return
Redirect
::
back
();
}
$enabled
=
!!
request
(
'enabled'
);
$data
=
[
'enabled'
=>
!!
request
(
'enabled'
),
];
$campaign
->
update
([
'enabled'
=>
$enabled
,
if
(
$data
[
'enabled'
])
{
$data
[
'groups_loaded_at'
]
=
null
;
$campaign
->
groups
()
->
update
([
'keywords_loaded_at'
=>
null
,
]);
}
$campaign
->
update
(
$data
);
$campaign
->
dictionaryCampaigns
()
->
update
([
'enabled'
=>
$enabled
,
'enabled'
=>
$
campaign
->
enabled
,
]);
return
Redirect
::
back
()
->
with
(
'success'
,
'Campaign '
.
(
$campaign
->
enabled
?
'enabled'
:
'disabled'
)
.
'.'
);
...
...
app/Service/Requests/Direct/GetKeywords.php
View file @
ff2fdde
...
...
@@ -126,9 +126,9 @@ class GetKeywords extends DirectRequest
'external_id'
=>
$external_id
],
$data
);
//
$ad_group->update([
//
'keywords_loaded_at' => Carbon::now(),
//
]);
$ad_group
->
update
([
'keywords_loaded_at'
=>
Carbon
::
now
(),
]);
}
else
{
$goalKeyword
=
GoalKeyword
::
firstWhere
(
'external_id'
,
$external_id
);
...
...
app/Service/Requests/Direct/UpdateAdGroups.php
View file @
ff2fdde
...
...
@@ -70,10 +70,15 @@ class UpdateAdGroups extends DirectRequest
}
}
public
function
putParams
(
$params
)
{
$this
->
goalAdGroups
=
$params
[
'goalAdGroups'
];
}
private
function
requestPrepare
(
$params
)
{
$this
->
setService
(
'AdGroups'
);
$this
->
setMethod
(
'
add
'
);
$this
->
setMethod
(
'
update
'
);
$this
->
putParams
(
$params
);
...
...
database/migrations/2021_06_02_10638_create_goal_ad_groups_table.php
View file @
ff2fdde
...
...
@@ -26,6 +26,7 @@ class CreateGoalAdGroupsTable extends Migration
$table
->
timestamp
(
'updated_need'
)
->
nullable
();
$table
->
timestamp
(
'updated_self'
)
->
nullable
();
$table
->
timestamps
();
$table
->
timestamps
();
$table
->
foreign
(
'dictionary_campaign_id'
)
->
references
(
'id'
)
->
on
(
'dictionary_campaigns'
)
...
...
@@ -42,6 +43,6 @@ class CreateGoalAdGroupsTable extends Migration
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'
dictionary_campaign
s'
);
Schema
::
dropIfExists
(
'
goal_ad_group
s'
);
}
}
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