Modified: branches/gsoc11-statistics/stats-server/app/controllers/installed_ports_controller.rb (116789 => 116790)
--- branches/gsoc11-statistics/stats-server/app/controllers/installed_ports_controller.rb 2014-02-07 19:29:46 UTC (rev 116789)
+++ branches/gsoc11-statistics/stats-server/app/controllers/installed_ports_controller.rb 2014-02-07 19:30:37 UTC (rev 116790)
@@ -21,7 +21,8 @@
sum = sum + user.installed_ports.count
end
- average = sum / users.count
+ return 0 unless users.count > 0
+ average = sum / users.count unless users.count == 0
end
# Find the port that has been installed most this year
@@ -39,8 +40,12 @@
# most populator port this year
popular_port_year = top.first
- @popular_port_year = Port.find(popular_port_year[0])
- @popular_port_year_count = popular_port_year[1]
+ @popular_port_year = nil
+ @popular_port_year_count = 0
+ unless popular_port_year == nil
+ @popular_port_year = Port.find(popular_port_year[0])
+ @popular_port_year_count = popular_port_year[1]
+ end
end
# Most popular port this month
@@ -110,4 +115,4 @@
end
end
-end
\ No newline at end of file
+end