app/models/visualization/collection.rb
def fetch(filters={})
        if filters[:only_shared].present? && filters[:only_shared].to_s == 'true'
          dataset = repository.collection
          dataset = filter_by_only_shared(dataset, filters)
        else
          dataset = repository.collection(filters,  %w{ user_id })
          locked_filter = filters.delete(:locked)
          unless locked_filter.nil?
            if locked_filter.to_s == 'true'
              locked_filter = true
              filters[:exclude_shared] = true
            else
              locked_filter = locked_filter.to_s == 'false' ? false : nil
            end
          end
          dataset = repository.apply_filters(dataset, {locked: locked_filter}, ['locked']) unless locked_filter.nil?
          dataset = include_shared_entities(dataset, filters)
        end

        if dataset.nil?
          @total_entries = 0
          collection.storage = Set.new
        else
          # 2) Filter
          dataset = repository.apply_filters(dataset, filters, AVAILABLE_FILTERS)
          dataset = filter_by_tags(dataset, tags_from(filters))
          dataset = filter_by_partial_match(dataset, filters.delete(:q))
          dataset = order(dataset, filters.delete(:o))

          @total_entries = dataset.count
          dataset = repository.paginate(dataset, filters)

          collection.storage = Set.new(dataset.map { |attributes|
            Visualization::Member.new(attributes)
          })
        end

        self
      end
# NOTES:
# - if user_id is present as filter, will fetch visualizations shared with the user,
#   except if exclude_shared filter is also present and true,
# - only_shared forces to use different flow because if there are no shared there's nothing else to do
# - locked filter has special behaviour
if user_id is present as filter, will fetch visualizations shared with the user,
except if exclude_shared filter is also present and true,
only_shared forces to use different flow because if there are no shared there's nothing else to do
locked filter has special behaviour
if user_id is present as filter will fetch visualizations shared with the user except if exclude_shared filter is also present and true only_shared forces to use different flow because if there are no shared there ' s nothing else to do locked filter has special behaviour
def fetch(filters={})
        if filters[:only_shared].present? && filters[:only_shared].to_s == 'true'
          dataset = repository.collection
          dataset = filter_by_only_shared(dataset, filters)
        else
          dataset = repository.collection(filters,  %w{ user_id })
          locked_filter = filters.delete(:locked)
          unless locked_filter.nil?
            if locked_filter.to_s == 'true'
              locked_filter = true
              filters[:exclude_shared] = true
            else
              locked_filter = locked_filter.to_s == 'false' ? false : nil
            end
          end
          dataset = repository.apply_filters(dataset, {locked: locked_filter}, ['locked']) unless locked_filter.nil?
          dataset = include_shared_entities(dataset, filters)
        end
        if dataset.nil?
          @total_entries = 0
          collection.storage = Set.new
        else
          dataset = repository.apply_filters(dataset, filters, AVAILABLE_FILTERS)
          dataset = filter_by_tags(dataset, tags_from(filters))
          dataset = filter_by_partial_match(dataset, filters.delete(:q))
          dataset = order(dataset, filters.delete(:o))
          @total_entries = dataset.count
          dataset = repository.paginate(dataset, filters)
          collection.storage = Set.new(dataset.map { |attributes|
            Visualization::Member.new(attributes)
          })
        end
        self
      end
def fetch ( filters = { } ) if filters [ :only_shared ] . present? && filters [ :only_shared ] . to_s == 'true' dataset = repository . collection dataset = filter_by_only_shared ( dataset , filters ) else dataset = repository . collection ( filters , %w{ user_id } ) locked_filter = filters . delete ( :locked ) unless locked_filter . nil? if locked_filter . to_s == 'true' locked_filter = true filters [ :exclude_shared ] = true else locked_filter = locked_filter . to_s == 'false' ? false : nil end end dataset = repository . apply_filters ( dataset , { locked : locked_filter } , [ 'locked' ] ) unless locked_filter . nil? dataset = include_shared_entities ( dataset , filters ) end if dataset . nil? @total_entries = 0 collection . storage = Set . new else dataset = repository . apply_filters ( dataset , filters , AVAILABLE_FILTERS ) dataset = filter_by_tags ( dataset , tags_from ( filters ) ) dataset = filter_by_partial_match ( dataset , filters . delete ( :q ) ) dataset = order ( dataset , filters . delete ( :o ) ) @total_entries = dataset . count dataset = repository . paginate ( dataset , filters ) collection . storage = Set . new ( dataset . map { | attributes | Visualization :: Member . new ( attributes ) } ) end self end
NOTES:
 if user_id is present as filter, will fetch visualizations shared with the user,
except if exclude_shared filter is also present and true,
 only_shared forces to use different flow because if there are no shared there's nothing else to do
 locked filter has special behaviour
NOTES : if user_id is present as filter will fetch visualizations shared with the user except if exclude_shared filter is also present and true only_shared forces to use different flow because if there are no shared there ' s nothing else to do locked filter has special behaviour
# 2) Filter
filters