lib/flapjack/gateways/email/rollup.html.erb in flapjack-1.6.0 vs lib/flapjack/gateways/email/rollup.html.erb in flapjack-2.0.0b1
- old
+ new
@@ -9,42 +9,43 @@
border: 1px solid #666;
padding: 4px;
}
</style>
-<p>Hi <%= @alert.contact_first_name %></p>
+<p>Hi <%= @alert.contact_name %></p>
-<p>You have <%= @alert.rollup_alerts.length %> alerting check<%= @alert.rollup_alerts.length == 1 ? '' : 's' %> as follows:</p>
+<% rollup_alerts_count = @alert.rollup_alerts.length -%>
+<p>You have <%= rollup_alerts_count %> alerting check<%= (rollup_alerts_count == 1) ? '' : 's' %> as follows:</p>
<table>
<tbody>
<tr>
<th>Check</th>
- <th>Entity</th>
<th>State</th>
<th>Duration</th>
<th>Summary</th>
</tr>
-<% @alert.rollup_alerts.sort_by {|entity_check, details| details['duration'] }.each do |rollup_alert| -%>
-<% r_entity, r_check = rollup_alert[0].split(':', 2) -%>
-<% state = rollup_alert[1]['state'] -%>
-<% duration = (ChronicDuration.output(rollup_alert[1]['duration'], :keep_zero => true) || '0 secs') -%>
-<% summary = rollup_alert[1]['summary'] -%>
+
+<% @alert.rollup_alerts.all.sort_by(&:duration).each do |rollup_alert|
+ check = rollup_alert.check
+ state = rollup_alert.state
+ duration = (ChronicDuration.output(rollup_alert.duration, :keep_zero => true) || '0 secs') -%>
+ summary = rollup_alert.summary
<tr>
- <td><%= r_check %></td>
- <td><%= r_entity %></td>
+ <td><%= check.name %></td>
<td><%= ['ok'].include?(state) ? state.upcase : state.titleize %></td>
<td><%= duration %></td>
<td><%= summary %></td>
</tr>
<% end %>
</tbody>
</table>
-<% if @alert.rollup == 'recovery' %>
- <p>As your email summary threshold is <%= @alert.rollup_threshold %>, we're taking your email alerts out of summary mode now. You'll now be emailed individually for each alerting check.</p>
+<% rollup_threshold = @alert.medium.rollup_threshold -%>
+<% if 'recovery'.eql?(@alert.rollup) %>
+ <p>As your email summary threshold is <%= rollup_threshold %>, we're taking your email alerts out of summary mode now. You'll now be emailed individually for each alerting check.</p>
<% else %>
- <p>Your email alerts are being summarised as your email summary threshold is set to <%= @alert.rollup_threshold %>. You'll receive summary emails like this one until your number of alerting checks falls below <%= @alert.rollup_threshold %>.</p>
+ <p>Your email alerts are being summarised as your email summary threshold is set to <%= rollup_threshold %>. You'll receive summary emails like this one until your number of alerting checks falls below <%= rollup_threshold %>.</p>
<% end %>
<p>Cheers,<br/>
Flapjack</p>