Commit feb94e8e authored by Pawel Chojnacki's avatar Pawel Chojnacki
Browse files

Move timeframe_start and timeframe_end to common query context

parent cceec81bd44f
......@@ -6,14 +6,13 @@ class AdditionalMetricsDeploymentQuery < BaseQuery
def query(deployment_id)
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_end: (deployment.created_at + 30.minutes).to_f
}
)
)
query_metrics(query_context)
end
end
end
......
......@@ -6,14 +6,7 @@ class AdditionalMetricsEnvironmentQuery < BaseQuery
def query(environment_id)
Environment.find_by(id: environment_id).try do |environment|
query_context = common_query_context(environment).merge(
{
timeframe_start: 8.hours.ago.to_f,
timeframe_end: Time.now.to_f
}
)
query_metrics(query_context)
query_metrics(common_query_context(environment))
end
end
end
......
......@@ -71,8 +71,10 @@ def matched_metrics
result.select { |group| group.metrics.any? }
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,
kube_namespace: environment.project.kubernetes_service&.actual_namespace || '',
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