def search_scope_id
      clean_scope_ids = if scope_id.is_a?(Hash)
                          scope_id.values
                        else
                          [scope_id].flatten
                        end

      conditions = []
      conditions << "decidim_scope_id IS NULL" if clean_scope_ids.delete("global")
      conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any?

      query.includes(:scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i))
    end
def search_scope_id
      clean_scope_ids = if scope_id.is_a?(Hash)
                          scope_id.values
                        else
                          [scope_id].flatten
                        end

      conditions = []
      conditions << "decidim_scope_id IS NULL" if clean_scope_ids.delete("global")
      conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any?

      query.includes(:scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i))
    end
Handles the scope_id filter. When we want to show only those that do not
 have a scope_id set, we cannot pass an empty String or nil because Searchlight
 will automatically filter out these params, so the method will not be used.
 Instead, we need to pass a fake ID and then convert it inside. In this case,
 in order to select those elements that do not have a scope_id set we use
 `"global"` as parameter, and in the method we do the needed changes to search
 properly.