Skip to content

Facet count not using main scope #26

Description

@frozeek

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions