Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facet count not using main scope #26

Open
frozeek opened this issue May 14, 2020 · 1 comment
Open

Facet count not using main scope #26

frozeek opened this issue May 14, 2020 · 1 comment

Comments

@frozeek
Copy link

frozeek commented May 14, 2020

Hi, I have the following scenario:

class Movie < ApplicationRecord
  belongs_to :genre
  scope :published, -> { where(published: true) }
end

class Genre < ApplicationRecord
  has_many :movies
end

class MovieSearch < FortyFacets::FacetSearch
  model 'Movie'
  scope :published
  facet :genre
end

With the following dataset:

Genre 1: { id: 1, name: 'Horror' }

Movie 1:  { name: "IT", genre_id: 1, published: true }
Movie 2:  { name: "IT IV", genre_id: 1, published: false }

The count for Genre 1 returns a count of 2 movies, even though Movie 2 is not published and the scope filters for published: true.

How can I make scopes to be used from facets?

Thank you.

@paulwalk
Copy link

I am seeing this problem too - scope is being ignored in the FortyFacets::FacetSearch class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants