codeforboston / legalhousing

MIT License
10 stars 27 forks source link

Feature/add phrase count to stats #112

Closed jmartini closed 7 years ago

jmartini commented 7 years ago

Adds counts for each discriminatory phrase to the stats object returned by StatsController.get_stats. Displays the returned counts as an unordered list in stats/index.html.erb.

I changed date_range in app/models/listing.rb to find Listing entries instead of PhraseListing entries for two reasons:

  1. It didn't make sense that querrying the listing model would return only PhraseListing entries. If we want a function to return PhraseListing entries, that should live in the PhraseListing model file
  2. This function was causing a lot of database queries which was very slow even with the few listings we have in our seed data. I suspect that this is a combination of PhraseListing being a join table and the way the function is written. Someone with more rails experience may have a better explanation for this.