diff options
author | Sean McGivern <sean@gitlab.com> | 2019-08-23 13:05:38 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-08-28 16:39:33 +0100 |
commit | 9bfb012a56918e3412ce767c19f5f9ca2329a78c (patch) | |
tree | 1939721d21ad320347d614fac8ff1c6a5ba9f24b /lib/gitlab/performance_bar | |
parent | 23c1cfcc110b52c1060f35a4a4a7816fb38adc6c (diff) | |
download | gitlab-ce-9bfb012a56918e3412ce767c19f5f9ca2329a78c.tar.gz |
Add top-level warnings key to performance bar responseperformance-bar-warnings
This key is useful to reduce the amount of logic needed on the frontend:
if `has_warnings` is true, then the frontend knows that the request in
question has warnings for some metric.
Diffstat (limited to 'lib/gitlab/performance_bar')
-rw-r--r-- | lib/gitlab/performance_bar/with_top_level_warnings.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/gitlab/performance_bar/with_top_level_warnings.rb b/lib/gitlab/performance_bar/with_top_level_warnings.rb new file mode 100644 index 00000000000..fb5c5c5959d --- /dev/null +++ b/lib/gitlab/performance_bar/with_top_level_warnings.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Gitlab + module PerformanceBar + module WithTopLevelWarnings + def results + results = super + + results.merge(has_warnings: has_warnings?(results)) + end + + def has_warnings?(results) + results[:data].any? do |_, value| + value[:warnings].present? + end + end + end + end +end |