Bug #158
closed
If facts are imported incorrectly or incompletely, the Statistics links does not work.
Added by Bash Shell almost 15 years ago.
Updated almost 15 years ago.
Description
If facts are imported incorrectly or incompletely, the Statistics links does not work:
The Statistics page says:
No Inventory data has been found - add some hosts and facts and try again
The following is shown on the Webrick console:
Processing StatisticsController#index (for 10.1.1.111 at 2010-01-18 17:11:37) [GET]
Parameters: {"action"=>"index", "controller"=>"statistics"}
undefined method `to_label' for nil:NilClass
Rendering template within layouts/standard
Completed in 11ms (View: 6, DB: 3) | 200 OK [http://xxxx/statistics]
Re-importing facts from the beginning does not seem to help.
- Assignee set to Ohad Levy
this diff hopefully gets the graph displayed, figuring out why there are wrong entries is another story:
diff --git a/app/models/host.rb b/app/models/host.rb
index 726d49f..72a6cba 100644
--- a/app/models/host.rb
+++ b/app/models/host.rb
@@ -336,7 +336,13 @@ class Host < Puppet::Rails::Host
# returns sorted hash
def self.count_distribution assocication
output = {}
- count(:group => assocication).each {|k,v| output[k.to_label] = v unless v == 0 }
+ count(:group => assocication).each do |k,v|
+ begin
+ output[k.to_label] = v unless v == 0
+ rescue
+ logger.info "skipped #{k} as it has has no label"
+ end
+ end
output
end
- Assignee deleted (
Ohad Levy)
Great, the missing records are skipped and the Statistics link works!
- Category set to Web Interface
- Assignee set to Ohad Levy
- Target version set to 0.1-4
- Status changed from New to Closed
Also available in: Atom
PDF