Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
project
Commits
b4f4fdd3
Commit
b4f4fdd3
authored
May 02, 2020
by
drumm
Browse files
Issue
#3117465
: Add project NID to project_usage_week_release table
parent
ac04fc86
Changes
2
Hide whitespace changes
Inline
Side-by-side
usage/project_usage.drush.inc
View file @
b4f4fdd3
...
...
@@ -82,7 +82,6 @@ function project_usage_retrieve_metadata() {
}
// Load information about projects.
$projdata
=
array
();
$query
=
new
EntityFieldQuery
();
$result
=
$query
->
entityCondition
(
'entity_type'
,
'node'
)
->
entityCondition
(
'bundle'
,
project_project_node_types
())
...
...
@@ -107,7 +106,6 @@ function project_usage_retrieve_metadata() {
$query
=
new
EntityFieldQuery
();
$result
=
$query
->
entityCondition
(
'entity_type'
,
'node'
)
->
entityCondition
(
'bundle'
,
project_release_release_node_types
())
->
fieldCondition
(
'field_release_vcs_label'
,
'value'
,
'master'
,
'<>'
)
->
execute
();
if
(
isset
(
$result
[
'node'
]))
{
foreach
(
array_chunk
(
array_keys
(
$result
[
'node'
]),
100
)
as
$releases
)
{
...
...
@@ -191,6 +189,7 @@ function drush_project_usage_import_usage_stats($week) {
$qcount
++
;
$query
->
values
([
'nid'
=>
$nid
,
'project_nid'
=>
$metadata
[
'projects'
][
$project_machine_name
],
'timestamp'
=>
$week
,
'count'
=>
$count
,
]);
...
...
usage/project_usage.install
View file @
b4f4fdd3
...
...
@@ -42,6 +42,49 @@ function project_usage_update_7000() {
db_drop_table
(
'project_usage_day'
);
}
/**
* Add {project_usage_week_release}.project_nid field.
*/
function
project_usage_update_7002
()
{
db_add_field
(
'project_usage_week_release'
,
'project_nid'
,
[
'description'
=>
'The {node}.nid of the release’s project.'
,
'type'
=>
'int'
,
'unsigned'
=>
TRUE
,
'not null'
=>
TRUE
,
'default'
=>
0
,
]);
}
/**
* Fill {project_usage_week_release}.project_nid field.
*/
function
project_usage_update_7003
()
{
$project_release_nids
=
[];
$result
=
(
new
EntityFieldQuery
())
->
entityCondition
(
'entity_type'
,
'node'
)
->
entityCondition
(
'bundle'
,
project_release_release_node_types
())
->
execute
();
if
(
isset
(
$result
[
'node'
]))
{
foreach
(
array_chunk
(
array_keys
(
$result
[
'node'
]),
100
)
as
$releases
)
{
foreach
(
node_load_multiple
(
$releases
,
array
(),
TRUE
)
as
$release
)
{
$project_release_nids
[
$release
->
field_release_project
[
LANGUAGE_NONE
][
0
][
'target_id'
]][]
=
$release
->
nid
;
}
}
}
foreach
(
$project_release_nids
as
$project_nid
=>
$release_nids
)
{
db_update
(
'project_usage_week_release'
)
->
condition
(
'nid'
,
[
$release_nids
])
->
fields
([
'project_nid'
=>
$project_nid
])
->
execute
();
}
}
/**
* Index {project_usage_week_release}.project_nid field.
*/
function
project_usage_update_7004
()
{
db_add_index
(
'project_usage_week_release'
,
'timestamp_project_count'
,
[
'timestamp'
,
'project_nid'
,
'count'
]);
}
/**
* Remove obsolete configuration.
*/
...
...
@@ -90,10 +133,10 @@ function project_usage_schema() {
);
$schema
[
'project_usage_week_release'
]
=
array
(
'description'
=>
'Table used to store weekly usage information by
project and {taxonomy_term_data}.tid
.'
,
'description'
=>
'Table used to store weekly usage information by
release
.'
,
'fields'
=>
array
(
'nid'
=>
array
(
'description'
=>
'Primary Key: The {node}.nid of the
project
.'
,
'description'
=>
'Primary Key: The {node}.nid of the
release
.'
,
'type'
=>
'int'
,
'unsigned'
=>
TRUE
,
'not null'
=>
TRUE
,
...
...
@@ -106,6 +149,13 @@ function project_usage_schema() {
'not null'
=>
TRUE
,
'default'
=>
0
,
),
'project_nid'
=>
[
'description'
=>
'The {node}.nid of the release’s project.'
,
'type'
=>
'int'
,
'unsigned'
=>
TRUE
,
'not null'
=>
TRUE
,
'default'
=>
0
,
],
'count'
=>
array
(
'description'
=>
'The number of requests.'
,
'type'
=>
'int'
,
...
...
@@ -115,6 +165,9 @@ function project_usage_schema() {
),
),
'primary key'
=>
array
(
'nid'
,
'timestamp'
),
'indexes'
=>
[
'timestamp_project_count'
=>
[
'timestamp'
,
'project_nid'
,
'count'
],
],
);
$schema
[
'cache_project_usage'
]
=
array
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment