Class: Analytics::CycleAnalytics::Stage
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Analytics::CycleAnalytics::Stage
- Includes:
- Parentable, Stageable, DatabaseEventTracking
- Defined in:
- app/models/analytics/cycle_analytics/stage.rb
Constant Summary collapse
- MAX_STAGES_PER_VALUE_STREAM =
15
- SNOWPLOW_ATTRIBUTES =
%i[ id created_at updated_at relative_position start_event_identifier end_event_identifier group_id start_event_label_id end_event_label_id hidden custom name group_value_stream_id ].freeze
Constants inherited from ApplicationRecord
Constants included from ResetOnUnionError
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary collapse
Methods included from Stageable
#default_stage?, #end_event, #end_event_identifier=, #end_event_label_based?, #events_hash_code, #matches_with_stage_params?, #params_for_end_event, #params_for_start_event, #start_event, #start_event_identifier=, #start_event_label_based?, #subject_class
Methods included from DatabaseEventTracking
#filtered_record_attributes, #publish_database_create_event, #publish_database_destroy_event, #publish_database_event, #publish_database_update_event
Methods inherited from ApplicationRecord
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from SensitiveSerializableHash
Class Method Details
.distinct_stages_within_hierarchy(namespace) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/analytics/cycle_analytics/stage.rb', line 24 def self.distinct_stages_within_hierarchy(namespace) # Looking up the whole hierarchy including all kinds (type) of Namespace records. # We're doing a custom traversal_ids query because: # - The traversal_ids based `self_and_descendants` doesn't include the ProjectNamespace records. # - The default recursive lookup also excludes the ProjectNamespace records. # # Related issue: https://gitlab.com/gitlab-org/gitlab/-/issues/386124 all_namespace_ids = Namespace .select(Arel.sql('namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)]').as('id')) .where("traversal_ids @> ('{?}')", namespace.id) with_preloaded_labels .where(parent_id: all_namespace_ids) .select("DISTINCT ON(stage_event_hash_id) #{quoted_table_name}.*") end |