Skip to content

Commit

Permalink
Merge pull request #185 from identity-research-lab/dont-hide-empty-ca…
Browse files Browse the repository at this point in the history
…tegories

Don't hide empty categories on codebook page
  • Loading branch information
CoralineAda authored Dec 2, 2024
2 parents f52c6b4 + bf2d851 commit 8f4e20a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/models/category_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit 8f4e20a

Please sign in to comment.