Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e9310d3e
Commit
e9310d3e
authored
Nov 20, 2019
by
allison.browne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add index and report aproximate grafana embeds
parent
ed243671
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
11 deletions
+27
-11
app/models/issue.rb
app/models/issue.rb
+2
-2
db/migrate/20191120200015_add_index_to_grafana_integrations.rb
...grate/20191120200015_add_index_to_grafana_integrations.rb
+15
-0
db/schema.rb
db/schema.rb
+1
-0
lib/gitlab/grafana_embed_usage_data.rb
lib/gitlab/grafana_embed_usage_data.rb
+6
-6
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+1
-1
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+2
-2
No files found.
app/models/issue.rb
View file @
e9310d3e
...
...
@@ -62,10 +62,10 @@ class Issue < ApplicationRecord
scope
:order_relative_position_asc
,
->
{
reorder
(
::
Gitlab
::
Database
.
nulls_last_order
(
'relative_position'
,
'ASC'
))
}
scope
:preload_associated_models
,
->
{
preload
(
:labels
,
project: :namespace
)
}
scope
:with_project_grafana_integration
,
->
{
include
s
(
project: :grafana_integration
).
where
(
projects:
{
grafana_integrations:
{
enabled:
true
}
}
)
}
scope
:with_project_grafana_integration
,
->
{
join
s
(
project: :grafana_integration
).
where
(
projects:
{
grafana_integrations:
{
enabled:
true
}
}
)
}
scope
:with_api_entity_associations
,
->
{
preload
(
:timelogs
,
:assignees
,
:author
,
:notes
,
:labels
,
project:
[
:route
,
{
namespace: :route
}]
)
}
scope
:grafana_embedded
,
->
{
where
(
'"issues"."description_html" LIKE \'%data-dashboard-url%\''
).
where
(
'"issues"."description" ~* "grafana_integrations"."grafana_url"
'
)
}
scope
:grafana_embedded
_aprox
,
->
{
where
(
'"issues"."description" ILIKE \'%\' || "grafana_integrations"."grafana_url" || \'%\'
'
)
}
scope
:public_only
,
->
{
where
(
confidential:
false
)
}
scope
:confidential_only
,
->
{
where
(
confidential:
true
)
}
...
...
db/migrate/20191120200015_add_index_to_grafana_integrations.rb
0 → 100644
View file @
e9310d3e
class
AddIndexToGrafanaIntegrations
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_concurrent_index
:grafana_integrations
,
:enabled
,
where:
'enabled IS TRUE'
end
def
down
remove_concurrent_index
:grafana_integrations
,
:enabled
end
end
db/schema.rb
View file @
e9310d3e
...
...
@@ -1888,6 +1888,7 @@ ActiveRecord::Schema.define(version: 2019_11_25_140458) do
t
.
string
"encrypted_token_iv"
,
limit:
255
,
null:
false
t
.
string
"grafana_url"
,
limit:
1024
,
null:
false
t
.
boolean
"enabled"
,
default:
false
,
null:
false
t
.
index
[
"enabled"
],
name:
"index_grafana_integrations_on_enabled"
,
where:
"(enabled IS TRUE)"
t
.
index
[
"project_id"
],
name:
"index_grafana_integrations_on_project_id"
end
...
...
lib/gitlab/grafana_embed_usage_data.rb
View file @
e9310d3e
...
...
@@ -4,12 +4,12 @@ module Gitlab
class
GrafanaEmbedUsageData
class
<<
self
def
issue_count
count
=
0
Issue
.
select
(
:id
).
with_project_grafana_integration
.
grafana_embedded
.
each_batch
do
|
issue_batch
|
count
+=
issue_batch
.
count
end
count
# rubocop:disable CodeReuse/ActiveRecord
Issue
.
joins
(
project: :grafana_integration
)
.
merge
(
Project
.
with_grafana_integration_enabled
)
.
where
(
"issues.description LIKE '%' || grafana_integrations.grafana_url || '%'"
)
.
count
# rubocop:enable CodeReuse/ActiveRecord
end
end
end
...
...
lib/gitlab/usage_data.rb
View file @
e9310d3e
...
...
@@ -84,7 +84,7 @@ module Gitlab
issues:
count
(
Issue
),
issues_with_associated_zoom_link:
count
(
ZoomMeeting
.
added_to_issue
),
issues_using_zoom_quick_actions:
count
(
ZoomMeeting
.
select
(
:issue_id
).
distinct
),
issues_with_embeded_grafana_charts:
::
Gitlab
::
GrafanaEmbedUsageData
.
issue_count
,
issues_with_embeded_grafana_charts
_aprox
:
::
Gitlab
::
GrafanaEmbedUsageData
.
issue_count
,
keys:
count
(
Key
),
label_lists:
count
(
List
.
label
),
lfs_objects:
count
(
LfsObject
),
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
e9310d3e
...
...
@@ -154,7 +154,7 @@ describe Gitlab::UsageData do
issues
issues_with_associated_zoom_link
issues_using_zoom_quick_actions
issues_with_embeded_grafana_charts
issues_with_embeded_grafana_charts
_aprox
keys
label_lists
labels
...
...
@@ -214,7 +214,7 @@ describe Gitlab::UsageData do
expect
(
count_data
[
:projects_with_error_tracking_enabled
]).
to
eq
(
1
)
expect
(
count_data
[
:issues_with_associated_zoom_link
]).
to
eq
(
2
)
expect
(
count_data
[
:issues_using_zoom_quick_actions
]).
to
eq
(
3
)
expect
(
count_data
[
:issues_with_embeded_grafana_charts
]).
to
eq
(
2
)
expect
(
count_data
[
:issues_with_embeded_grafana_charts
_aprox
]).
to
eq
(
2
)
expect
(
count_data
[
:clusters_enabled
]).
to
eq
(
4
)
expect
(
count_data
[
:project_clusters_enabled
]).
to
eq
(
3
)
...
...
Write
Preview
Markdown
is supported
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