diff --git a/notifier/charts/execution_histogram.rb b/notifier/charts/execution_histogram.rb
index 3c610bfa86fe80a2485f1120375fc1230cb350da..7db70d30edeff2ccbbf0462fd5e499c22fca13d3 100644
--- a/notifier/charts/execution_histogram.rb
+++ b/notifier/charts/execution_histogram.rb
@@ -28,6 +28,10 @@ module Charts
5.minutes
].freeze
+ PLACEHOLDER_TEMPLATE = 'templates/charts/placeholder.erb'
+
+ HISTOGRAM_TEMPLATE = 'templates/charts/histogram.erb'
+
attr_reader :query_executions, :buckets, :title, :column_label
def self.for_result(result)
@@ -82,10 +86,14 @@ module Charts
end
end
- def render
- return '' if query_executions.empty?
+ def template
+ return PLACEHOLDER_TEMPLATE if query_executions.empty?
- ERB.new(File.read('templates/charts/histogram.erb'), trim_mode: '-').result(binding)
+ HISTOGRAM_TEMPLATE
+ end
+
+ def render
+ ERB.new(File.read(template), trim_mode: '-').result(binding)
end
end
end
diff --git a/notifier/spec/charts/execution_histogram_spec.rb b/notifier/spec/charts/execution_histogram_spec.rb
index a21bbc58721eb7cbf1d8ac161626fa0fbad09117..95a0dd3ff3cdd487c926eeace716775725f3e327 100644
--- a/notifier/spec/charts/execution_histogram_spec.rb
+++ b/notifier/spec/charts/execution_histogram_spec.rb
@@ -37,6 +37,18 @@ RSpec.describe Charts::ExecutionHistogram do
end
end
+ describe '#template' do
+ context 'when executions are empty' do
+ let(:executions) { [] }
+
+ it { expect(subject.template).to eq('templates/charts/placeholder.erb') }
+ end
+
+ context "when there's executions to render" do
+ it { expect(subject.template).to eq('templates/charts/histogram.erb') }
+ end
+ end
+
describe '#render' do
it 'renders' do
rendered = subject.render
diff --git a/notifier/spec/fixtures/migration-testing/v4/expected-comment.txt b/notifier/spec/fixtures/migration-testing/v4/expected-comment.txt
index 7a3ec051a07940f2c1a5c0e023d5c8cd1b4eb6a0..3e897a3ef3ddeb8dcd0d9fa08e3cd8a3ea9ec184 100644
--- a/notifier/spec/fixtures/migration-testing/v4/expected-comment.txt
+++ b/notifier/spec/fixtures/migration-testing/v4/expected-comment.txt
@@ -88,6 +88,8 @@ Migrations included in this change have been executed on gitlab.com data for tes
* Database size change: +0.00 B
+No histogram available for visualization
+
#### Migration: 20220223163519 - EnsureGitlabComInMigrations
* Type: Regular
@@ -95,6 +97,8 @@ Migrations included in this change have been executed on gitlab.com data for tes
* Database size change: +0.00 B
+No histogram available for visualization
+
#### Migration: 20220318174439 - QueueTestBackgroundMigration
* Type: Regular
@@ -102,6 +106,8 @@ Migrations included in this change have been executed on gitlab.com data for tes
* Database size change: +0.00 B
+No histogram available for visualization
+
#### Migration: 20210604232017 - DropTestTable
* Type: Post deploy
@@ -132,6 +138,8 @@ Migrations included in this change have been executed on gitlab.com data for tes
* Database size change: +0.00 B
+No histogram available for visualization
+
---
@@ -267,6 +275,8 @@ Migrations included in this change have been executed on gitlab.com data for tes
* Database size change: +0.00 B
+No histogram available for visualization
+
#### Migration: 20220223163519 - EnsureGitlabComInMigrations
* Type: Regular
@@ -274,6 +284,8 @@ Migrations included in this change have been executed on gitlab.com data for tes
* Database size change: +0.00 B
+No histogram available for visualization
+
#### Migration: 20220318174439 - QueueTestBackgroundMigration
* Type: Regular
@@ -281,6 +293,8 @@ Migrations included in this change have been executed on gitlab.com data for tes
* Database size change: +0.00 B
+No histogram available for visualization
+
#### Migration: 20210604232017 - DropTestTable
* Type: Post deploy
@@ -311,6 +325,8 @@ Migrations included in this change have been executed on gitlab.com data for tes
* Database size change: +0.00 B
+No histogram available for visualization
+
---
diff --git a/notifier/templates/charts/placeholder.erb b/notifier/templates/charts/placeholder.erb
new file mode 100644
index 0000000000000000000000000000000000000000..7cebb980029f7790f0d2974865ed352747cad008
--- /dev/null
+++ b/notifier/templates/charts/placeholder.erb
@@ -0,0 +1,3 @@
+No histogram available for visualization
+
+<% # The blank line above is important, without it the messes up markdown later in the file %>
\ No newline at end of file