Commit 7fde8caa authored by allison.browne's avatar allison.browne

Query for data-dashboard-url attribute

Query for  data-dashboard-url attribute to get the usage ping
data for grafana embeds
parent ca6a745c
......@@ -13,6 +13,7 @@ module Banzai
doc.document.create_element(
'div',
class: 'js-render-metrics',
# Grafana usage ping depends on this implementation
'data-dashboard-url': metrics_dashboard_url(params)
)
end
......
......@@ -4,20 +4,9 @@ module Gitlab
class GrafanaEmbedUsageData
class << self
def issue_count
Issue.with_project_grafana_integration.find_each.count do |issue|
has_grafana_url?(issue)
end
end
private
def has_grafana_url?(issue)
html = Banzai.render(issue.description, project: issue.project)
result = Banzai::Filter::InlineGrafanaMetricsFilter.new(
html, { project: issue.project }
).call
metric_node = result.at_css('.js-render-metrics')
metric_node ? metric_node&.attribute('data-dashboard-url').to_s : nil
Issue.with_project_grafana_integration.where(
Issue.arel_table[:description_html].matches('%data-dashboard-url%')
).count
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment