diff options
author | Mark Longair <mhl@pobox.com> | 2013-08-20 11:15:32 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-08-20 12:11:45 +0100 |
commit | 4656b24591593bdf5521030ce6bdf68baec6d160 (patch) | |
tree | 73814741fa99ca7fa007674a5f9ac145b56272f5 | |
parent | 2e30db88c6d6576e32c2329f7ff75fca7cca8ed9 (diff) |
Don't include NULL column values in the statistics
We were already excluding graphs where all the data was NULL
but it's possible by directly manipulating the database to
have some values NULL and some non-NULL, so exclude any NULL
values anyway.
-rw-r--r-- | app/models/public_body.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 436418fe5..300fdb956 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -658,7 +658,7 @@ class PublicBody < ActiveRecord::Base ordering = "y_value" ordering += " DESC" if highest y_value_column = "(cast(#{column} as float) / #{total_column})" - where_clause = "#{total_column} >= #{minimum_requests}" + where_clause = "#{total_column} >= #{minimum_requests} AND #{column} IS NOT NULL" public_bodies = PublicBody.select("*, #{y_value_column} AS y_value").order(ordering).where(where_clause).limit(n) public_bodies.reverse! if highest y_values = public_bodies.map { |pb| pb.y_value.to_f } |