Snorby/snorby

Dashboard page breaks when order by matches higher than result limit

wnormand-armor opened this issue · 0 comments

I know this isn't an active project but we hit this bug on our production server and it took a while to pin down. To reproduce, create about 10 sensors, set all of them to events_count=0, load the page. The limit=5 will load 5 objects, but the view will then load another 5 objects since it's an unordered collection. I was able to work around this by forcing the sensor to an array before passing to the view.

https://github.com/Snorby/snorby/blob/master/app/controllers/page_controller.rb#L46

-@sensors = Sensor.all(:limit => 5, :order => [:events_count.desc])
+@sensors = Sensor.all(:limit => 5, :order => [:events_count.desc]).to_a # eagerly load the initial result set