app/models/ordering_entry_candidate.rb
# Build a SQL query that orders a subset of {OrderingEntryCandidate} by whatever
# an {Ordering} is {Schemas::Orderings::Definition is looking for}.
#
# @param [Ordering] ordering
# @return [ActiveRecord::Relation<OrderingEntryCandidate>]
Build a SQL query that orders a subset of {OrderingEntryCandidate} by whatever
an {Ordering} is {Schemas::Orderings::Definition is looking for}.
Build a SQL query that orders a subset of { OrderingEntryCandidate } by whatever an { Ordering } is { Schemas :: Orderings :: Definition is looking for } .
def query_for(ordering)
      base_query = build_projection_and_joins_for(ordering).
        with_schema_selector_for(ordering).
        with_child_selector_for(ordering).
        with_link_selector_for(ordering)
      return base_query unless ordering.tree_mode?
      entity = ordering.entity
      stats_query = TREE_STATS_QUERY % connection.quote(entity.auth_path)
      all.with(
        stats: stats_query,
        flat_candidates: base_query,
        scored_candidates: SCORED_CANDIDATES_QUERY,
        remapped_candidates: REMAPPED_CANDIDATES_QUERY
      ).select(
        "ordering_id", "entity_id", "entity_type", "position", "inverse_position", "link_operator", "auth_path", "scope", "relative_depth",
        "tree_depth", "tree_parent_id", "tree_parent_type"
      ).from("remapped_candidates").order(position: :asc)
    end
def query_for ( ordering ) base_query = build_projection_and_joins_for ( ordering ) . with_schema_selector_for ( ordering ) . with_child_selector_for ( ordering ) . with_link_selector_for ( ordering ) return base_query unless ordering . tree_mode? entity = ordering . entity stats_query = TREE_STATS_QUERY % connection . quote ( entity . auth_path ) all . with ( stats : stats_query , flat_candidates : base_query , scored_candidates : SCORED_CANDIDATES_QUERY , remapped_candidates : REMAPPED_CANDIDATES_QUERY ) . select ( "ordering_id" , "entity_id" , "entity_type" , "position" , "inverse_position" , "link_operator" , "auth_path" , "scope" , "relative_depth" , "tree_depth" , "tree_parent_id" , "tree_parent_type" ) . from ( "remapped_candidates" ) . order ( position : :asc ) end
Build a SQL query that orders a subset of {OrderingEntryCandidate} by whatever
an {Ordering} is {Schemas::Orderings::Definition is looking for}.
Build a SQL query that orders a subset of { OrderingEntryCandidate } by whatever an { Ordering } is { Schemas :: Orderings :: Definition is looking for } .
None
ActiveRecord::Relation<OrderingEntryCandidate>
ordering
None