Commit feb94e8e authored by Pawel Chojnacki's avatar Pawel Chojnacki

Move timeframe_start and timeframe_end to common query context

parent b243c3ea
...@@ -6,14 +6,13 @@ module Gitlab ...@@ -6,14 +6,13 @@ module Gitlab
def query(deployment_id) def query(deployment_id)
Deployment.find_by(id: deployment_id).try do |deployment| Deployment.find_by(id: deployment_id).try do |deployment|
query_context = common_query_context(deployment.environment).merge( query_metrics(
{ common_query_context(
deployment.environment,
timeframe_start: (deployment.created_at - 30.minutes).to_f, timeframe_start: (deployment.created_at - 30.minutes).to_f,
timeframe_end: (deployment.created_at + 30.minutes).to_f timeframe_end: (deployment.created_at + 30.minutes).to_f
}
) )
)
query_metrics(query_context)
end end
end end
end end
......
...@@ -6,14 +6,7 @@ module Gitlab ...@@ -6,14 +6,7 @@ module Gitlab
def query(environment_id) def query(environment_id)
Environment.find_by(id: environment_id).try do |environment| Environment.find_by(id: environment_id).try do |environment|
query_context = common_query_context(environment).merge( query_metrics(common_query_context(environment))
{
timeframe_start: 8.hours.ago.to_f,
timeframe_end: Time.now.to_f
}
)
query_metrics(query_context)
end end
end end
end end
......
...@@ -71,8 +71,10 @@ module Gitlab ...@@ -71,8 +71,10 @@ module Gitlab
result.select { |group| group.metrics.any? } result.select { |group| group.metrics.any? }
end end
def common_query_context(environment) def common_query_context(environment, timeframe_start: 8.hours.ago.to_f, timeframe_end: Time.now.to_f)
{ {
timeframe_start: timeframe_start,
timeframe_end: timeframe_end,
ci_environment_slug: environment.slug, ci_environment_slug: environment.slug,
kube_namespace: environment.project.kubernetes_service&.actual_namespace || '', kube_namespace: environment.project.kubernetes_service&.actual_namespace || '',
environment_filter: %{container_name!="POD",environment="#{environment.slug}"} environment_filter: %{container_name!="POD",environment="#{environment.slug}"}
......
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