There is at least one other case where the list has been specifically open coded, and when I asked Nick whether the set of statuses was closed, I got a fairly emphatic positive response.
I'm content to leave this open coded here for now. On Fri, Jul 22, 2011 at 3:18 PM, Daniel Pittman <[email protected]>wrote: > On Fri, Jul 22, 2011 at 14:30, Pieter van de Bruggen > <[email protected]> wrote: > > Reviewed-By: Mike Stahnke > > > > Signed-off-by: Pieter van de Bruggen <[email protected]> > > --- > > Local-branch: tickets/1.2rc/8589 > > app/views/reports/_resource_statuses.html.haml | 2 +- > > lib/core_callbacks.rb | 6 +++--- > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/app/views/reports/_resource_statuses.html.haml > b/app/views/reports/_resource_statuses.html.haml > > index d3ea038..d862706 100644 > > --- a/app/views/reports/_resource_statuses.html.haml > > +++ b/app/views/reports/_resource_statuses.html.haml > > @@ -7,7 +7,7 @@ > > %dl.expandable-list > > - statuses.each do |status, resources| > > %h3 #{status.titleize} (#{resources.count}) > > - - resources.sort_by(&:time).each do |status| > > + - resources.each do |status| > > - index += 1 > > %dt{:class => cycle( 'odd', 'even' )} > > - if status.events.empty? > > diff --git a/lib/core_callbacks.rb b/lib/core_callbacks.rb > > index 9ba3c24..2fd8b07 100644 > > --- a/lib/core_callbacks.rb > > +++ b/lib/core_callbacks.rb > > @@ -37,9 +37,9 @@ end > > > > # Report view widgets > > Registry.add_callback :core, :report_view_widgets, > "800_resource_statuses" do |view_renderer, report| > > - statuses = report.resource_statuses.group_by(&:status).sort > > - if failed = statuses.index {|s,rs| s == 'failed'} then > statuses.unshift(statuses.delete_at(failed)) end > > - view_renderer.render 'reports/resource_statuses', :report => report, > :statuses => statuses > > + statuses = report.resource_statuses.all(:order => 'resource_type, > title').group_by(&:status) > > + statuses = %w[failed pending changed unchanged].map { |k| (v = > statuses[k]) && [k, v] } > > Doesn't this code require hand-attention when we add a new status? I > understand that is a costly event, but we should probably make this > sort appropriately, or at least find any unknown status names and > append them to the end of that array. That way we don't omit them > entirely from the view of consumers of this data. > > daniel > -- > ⎋ Puppet Labs Developer – http://puppetlabs.com > ♲ Made with 100 percent post-consumer electrons > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/puppet-dev?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
