Module: Gitlab::DatabaseImporters::WorkItems::BaseTypeImporter
- Defined in:
- lib/gitlab/database_importers/work_items/base_type_importer.rb
Constant Summary collapse
- WIDGET_NAMES =
{ assignees: 'Assignees', labels: 'Labels', description: 'Description', hierarchy: 'Hierarchy', start_and_due_date: 'Start and due date', milestone: 'Milestone', notes: 'Notes', iteration: 'Iteration', weight: 'Weight', health_status: 'Health status', progress: 'Progress', status: 'Status', requirement_legacy: 'Requirement legacy', test_reports: 'Test reports', notifications: 'Notifications', current_user_todos: 'Current user todos', award_emoji: 'Award emoji', linked_items: 'Linked items' }.freeze
- WIDGETS_FOR_TYPE =
{ issue: [ :assignees, :labels, :description, :hierarchy, :start_and_due_date, :milestone, :notes, :iteration, :weight, :health_status, :notifications, :current_user_todos, :award_emoji, :linked_items ], incident: [ :assignees, :description, :hierarchy, :notes, :notifications, :current_user_todos, :award_emoji, :linked_items ], test_case: [ :description, :notes, :notifications, :current_user_todos, :award_emoji, :linked_items ], requirement: [ :description, :notes, :status, :requirement_legacy, :test_reports, :notifications, :current_user_todos, :award_emoji, :linked_items ], task: [ :assignees, :labels, :description, :hierarchy, :start_and_due_date, :milestone, :notes, :iteration, :weight, :notifications, :current_user_todos, :award_emoji, :linked_items ], objective: [ :assignees, :labels, :description, :hierarchy, :milestone, :notes, :health_status, :progress, :notifications, :current_user_todos, :award_emoji, :linked_items ], key_result: [ :assignees, :labels, :description, :hierarchy, :start_and_due_date, :notes, :health_status, :progress, :notifications, :current_user_todos, :award_emoji, :linked_items ], epic: [ :assignees, :description, :hierarchy, :labels, :notes, :start_and_due_date, :health_status, :status, :notifications, :current_user_todos, :award_emoji, :linked_items ], ticket: [ :assignees, :labels, :description, :hierarchy, :start_and_due_date, :milestone, :notes, :iteration, :weight, :health_status, :notifications, :current_user_todos, :award_emoji, :linked_items ] }.freeze
Class Method Summary collapse
Class Method Details
.upsert_types ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/gitlab/database_importers/work_items/base_type_importer.rb', line 149 def self.upsert_types current_time = Time.current base_types = ::WorkItems::Type::BASE_TYPES.map do |type, attributes| attributes.slice(:name, :icon_name) .merge(created_at: current_time, updated_at: current_time, base_type: type) end ::WorkItems::Type.upsert_all( base_types, unique_by: :idx_work_item_types_on_namespace_id_and_name_null_namespace ) end |
.upsert_widgets ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/gitlab/database_importers/work_items/base_type_importer.rb', line 165 def self. type_ids_by_name = ::WorkItems::Type.default.pluck(:name, :id).to_h # rubocop: disable CodeReuse/ActiveRecord = WIDGETS_FOR_TYPE.flat_map do |type_sym, | type_name = ::WorkItems::Type::TYPE_NAMES[type_sym] .map do || { work_item_type_id: type_ids_by_name[type_name], name: WIDGET_NAMES[], widget_type: ::WorkItems::WidgetDefinition.[] } end end ::WorkItems::WidgetDefinition.upsert_all( , unique_by: :index_work_item_widget_definitions_on_default_witype_and_name ) end |