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 7c551ac6
authored
Jun 07, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19473 Получение кеша фраз
1 parent
b9c066d8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
221 additions
and
0 deletions
app/Models/AdGroup.php
app/Models/Keyword.php
app/Models/Pivots/GoalAdGroup.php
database/migrations/2021_05_14_094834_create_ad_groups_table.php
database/migrations/2021_06_02_10638_create_goal_ad_groups_table.php
database/migrations/2021_06_07_08638_create_keywords_table.php
database/migrations/2021_06_07_11420_create_goal_keywords_table.php
app/Models/AdGroup.php
View file @
7c551ac
...
@@ -101,6 +101,7 @@ class AdGroup extends Model
...
@@ -101,6 +101,7 @@ class AdGroup extends Model
'serving_status'
,
'serving_status'
,
'restricted_region_ids'
,
'restricted_region_ids'
,
'updated_self'
,
'updated_self'
,
'keywords_loaded_at'
,
];
];
protected
$casts
=
[
protected
$casts
=
[
...
@@ -118,6 +119,7 @@ class AdGroup extends Model
...
@@ -118,6 +119,7 @@ class AdGroup extends Model
'smart_ad_group'
=>
'json'
,
'smart_ad_group'
=>
'json'
,
'restricted_region_ids'
=>
'json'
,
'restricted_region_ids'
=>
'json'
,
'updated_self'
=>
'datetime'
,
'updated_self'
=>
'datetime'
,
'keywords_loaded_at'
=>
'datetime'
,
];
];
/**
/**
...
...
app/Models/Keyword.php
0 → 100644
View file @
7c551ac
<?php
namespace
App\Models
;
use
App\Models\Pivots\GoalAdGroup
;
use
Carbon\Carbon
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Support\Collection
;
class
Keyword
extends
Model
{
const
STATE_OFF
=
'OFF'
;
const
STATE_ON
=
'ON'
;
const
STATE_SUSPENDED
=
'SUSPENDED'
;
const
STATUS_ACCEPTED
=
'ACCEPTED'
;
const
STATUS_DRAFT
=
'DRAFT'
;
const
STATUS_REJECTED
=
'REJECTED'
;
const
STATUS_UNKNOWN
=
'UNKNOWN'
;
const
SERVING_STATUS_ELIGIBLE
=
'ELIGIBLE'
;
const
SERVING_STATUS_RARELY_SERVED
=
'RARELY_SERVED'
;
protected
$fillable
=
[
'external_id'
,
'ad_group_external_id'
,
'ad_group_id'
,
'keyword'
,
'user_param_1'
,
'user_param_2'
,
'bid'
,
'context_bid'
,
'state'
,
'status'
,
'serving_status'
,
'statistics_search'
,
'statistics_network'
,
];
protected
$casts
=
[
'external_id'
=>
'int'
,
'ad_group_external_id'
=>
'int'
,
'ad_group_id'
=>
'int'
,
'bid'
=>
'int'
,
'context_bid'
=>
'int'
,
'statistics_search'
=>
'json'
,
'statistics_network'
=>
'json'
,
];
/**
* @return Collection
*/
static
public
function
getPropertiesWatch
()
{
return
collect
([
'ad_group_external_id'
,
'keyword'
,
'user_param_1'
,
'user_param_2'
,
'bid'
,
'context_bid'
,
'state'
,
'status'
,
'serving_status'
,
'statistics_search'
,
'statistics_network'
,
]);
}
public
static
function
boot
()
{
parent
::
boot
();
static
::
created
(
function
(
Keyword
$keyword
)
{
//
});
static
::
updated
(
function
(
Keyword
$keyword
)
{
if
(
GoalKeyword
::
getPropertiesCopyWithPivot
()
->
first
(
function
(
$property_name
)
use
(
$keyword
)
{
return
$keyword
->
{
$property_name
}
!==
$keyword
->
getOriginal
(
$property_name
);
}))
{
$keyword
->
goalKeywords
()
->
update
(
GoalKeyword
::
copyPropertyFromMain
(
$keyword
)
);
}
if
(
self
::
getPropertiesWatch
()
->
first
(
function
(
$property_name
)
use
(
$keyword
)
{
return
$keyword
->
{
$property_name
}
!==
$keyword
->
getOriginal
(
$property_name
);
}))
{
$keyword
->
goalKeywords
()
->
update
([
'updated_need'
=>
Carbon
::
now
(),
]);
}
});
}
public
function
goalKeywords
()
{
return
$this
->
hasMany
(
GoalKeyword
::
class
,
'keyword_id'
);
}
public
function
group
()
{
return
$this
->
belongsTo
(
AdGroup
::
class
,
'ad_group_id'
);
}
}
app/Models/Pivots/GoalAdGroup.php
View file @
7c551ac
...
@@ -68,6 +68,7 @@ class GoalAdGroup extends Pivot
...
@@ -68,6 +68,7 @@ class GoalAdGroup extends Pivot
'external_updated_at'
,
'external_updated_at'
,
'updated_need'
,
'updated_need'
,
'updated_self'
,
'updated_self'
,
'keywords_loaded_at'
,
];
];
protected
$casts
=
[
protected
$casts
=
[
...
@@ -80,6 +81,7 @@ class GoalAdGroup extends Pivot
...
@@ -80,6 +81,7 @@ class GoalAdGroup extends Pivot
'external_updated_at'
=>
'datetime'
,
'external_updated_at'
=>
'datetime'
,
'updated_need'
=>
'datetime'
,
'updated_need'
=>
'datetime'
,
'updated_self'
=>
'datetime'
,
'updated_self'
=>
'datetime'
,
'keywords_loaded_at'
=>
'datetime'
,
];
];
static
public
function
getWithPivot
()
static
public
function
getWithPivot
()
...
@@ -96,6 +98,7 @@ class GoalAdGroup extends Pivot
...
@@ -96,6 +98,7 @@ class GoalAdGroup extends Pivot
'external_updated_at'
,
'external_updated_at'
,
'updated_self'
,
'updated_self'
,
'updated_need'
,
'updated_need'
,
'keywords_loaded_at'
,
];
];
}
}
...
...
database/migrations/2021_05_14_094834_create_ad_groups_table.php
View file @
7c551ac
...
@@ -58,6 +58,7 @@ class CreateAdGroupsTable extends Migration
...
@@ -58,6 +58,7 @@ class CreateAdGroupsTable extends Migration
])
->
nullable
();
])
->
nullable
();
$table
->
json
(
'restricted_region_ids'
)
->
nullable
();
$table
->
json
(
'restricted_region_ids'
)
->
nullable
();
$table
->
timestamp
(
'updated_self'
)
->
nullable
();
$table
->
timestamp
(
'updated_self'
)
->
nullable
();
$table
->
timestamp
(
'keywords_loaded_at'
)
->
nullable
();
$table
->
timestamps
();
$table
->
timestamps
();
...
...
database/migrations/2021_06_02_10638_create_goal_ad_groups_table.php
View file @
7c551ac
...
@@ -25,6 +25,7 @@ class CreateGoalAdGroupsTable extends Migration
...
@@ -25,6 +25,7 @@ class CreateGoalAdGroupsTable extends Migration
$table
->
timestamp
(
'external_updated_at'
)
->
nullable
();
$table
->
timestamp
(
'external_updated_at'
)
->
nullable
();
$table
->
timestamp
(
'updated_need'
)
->
nullable
();
$table
->
timestamp
(
'updated_need'
)
->
nullable
();
$table
->
timestamp
(
'updated_self'
)
->
nullable
();
$table
->
timestamp
(
'updated_self'
)
->
nullable
();
$table
->
timestamp
(
'keywords_loaded_at'
)
->
nullable
();
$table
->
timestamps
();
$table
->
timestamps
();
...
...
database/migrations/2021_06_07_08638_create_keywords_table.php
0 → 100644
View file @
7c551ac
<?php
use
App\Models\Keyword
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateKeywordsTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'keywords'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
bigInteger
(
'external_id'
)
->
nullable
();
$table
->
bigInteger
(
'ad_group_external_id'
)
->
nullable
();
$table
->
bigInteger
(
'ad_group_id'
)
->
unsigned
();
$table
->
text
(
'keyword'
)
->
nullable
();
$table
->
string
(
'user_param_1'
,
255
)
->
nullable
();
$table
->
string
(
'user_param_2'
,
255
)
->
nullable
();
$table
->
bigInteger
(
'bid'
)
->
nullable
();
$table
->
bigInteger
(
'context_bid'
)
->
nullable
();
$table
->
enum
(
'state'
,
[
Keyword
::
STATE_OFF
,
Keyword
::
STATE_ON
,
Keyword
::
STATE_SUSPENDED
,
])
->
nullable
();
$table
->
enum
(
'status'
,
[
Keyword
::
STATUS_ACCEPTED
,
Keyword
::
STATUS_DRAFT
,
Keyword
::
STATUS_REJECTED
,
Keyword
::
STATUS_UNKNOWN
,
])
->
nullable
();
$table
->
enum
(
'serving_status'
,
[
Keyword
::
SERVING_STATUS_ELIGIBLE
,
Keyword
::
SERVING_STATUS_RARELY_SERVED
,
])
->
nullable
();
$table
->
json
(
'statistics_search'
)
->
nullable
();
$table
->
json
(
'statistics_network'
)
->
nullable
();
$table
->
timestamps
();
$table
->
foreign
(
'ad_group_id'
)
->
references
(
'id'
)
->
on
(
'ad_groups'
)
->
cascadeOnDelete
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'keywords'
);
}
}
database/migrations/2021_06_07_11420_create_goal_keywords_table.php
0 → 100644
View file @
7c551ac
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateGoalKeywordsTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'goal_keywords'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
bigInteger
(
'external_id'
)
->
nullable
();
$table
->
bigInteger
(
'goal_ad_group_external_id'
)
->
nullable
();
$table
->
bigInteger
(
'goal_ad_group_id'
)
->
unsigned
();
$table
->
bigInteger
(
'keyword_id'
)
->
unsigned
();
$table
->
timestamp
(
'external_upload_at'
)
->
nullable
();
$table
->
timestamp
(
'external_updated_at'
)
->
nullable
();
$table
->
timestamp
(
'updated_need'
)
->
nullable
();
$table
->
timestamps
();
$table
->
foreign
(
'ad_group_id'
)
->
references
(
'id'
)
->
on
(
'ad_groups'
)
->
cascadeOnDelete
();
$table
->
foreign
(
'keyword_id'
)
->
references
(
'id'
)
->
on
(
'keywords'
)
->
cascadeOnDelete
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'goal_keywords'
);
}
}
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