diff --git a/app/models/category.rb b/app/models/category.rb index a0a3138..59e8b84 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -18,7 +18,7 @@ class Category # Generates a hash with the unique category name as the key and the count of its associated codes as a value. def self.histogram(context) - categories = where(context: context).query_as(:c).with('c, count{(c)-[:CATEGORIZED_AS]-(code:Code)} AS ct').where('ct > 0').return("c.name, ct").order('ct DESC') + categories = where(context: context).query_as(:c).with('c, count{(c)-[:CATEGORIZED_AS]-(code:Code)} AS ct').return("c.name, ct").order('ct DESC') categories.inject({}) {|accumulator,category| accumulator[category.values[0]] ||= 0; accumulator[category.values[0]] += category.values[1]; accumulator} end diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index b777a9a..d2f5549 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Category do before do - allow(Category).to receive_message_chain(:where, :query_as, :with, :where, :return, :order).and_return(response) + allow(Category).to receive_message_chain(:where, :query_as, :with, :return, :order).and_return(response) end let(:result_set) { Struct.new(:values) }