提交 feb94e8e 编写于 作者: P Pawel Chojnacki

Move timeframe_start and timeframe_end to common query context

上级 b243c3ea
......@@ -6,14 +6,13 @@ module Gitlab
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 @@ module Gitlab
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 @@ module Gitlab
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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册