Skip to content

Draft: Transition mapping from system defined status to custom status

What does this MR do and why?

Destructive actions suggested!

SQL

select issues.id, work_item_current_statuses.system_defined_status_id, work_item_current_statuses.custom_status_id 
from issues 
left outer join work_item_current_statuses on work_item_current_statuses.work_item_id = issues.id 
where (work_item_current_statuses.system_defined_status_id = 1 or work_item_current_statuses.system_defined_status_id is null or work_item_current_statuses.custom_status_id = 6594) order by issues.updated_at desc limit 10;

Scenario 1: Work Items open and closed state lists with status without backfilling

  1. Cleanup all your statuses data:
  WorkItems::Statuses::CurrentStatus.delete_all
  WorkItems::Statuses::Custom::Status.delete_all
  WorkItems::Statuses::Custom::Lifecycle.delete_all
  WorkItems::TypeCustomLifecycle.delete_all
  WorkItems::Statuses::Custom::LifecycleStatus.delete_all
  WorkItems::Statuses::Custom::TransitionMapping.delete_all
  1. Check out the Open issues list
  2. Note that all items in the list show the default open status without backfilling
  3. Check out the Closed issues list
  4. Note that all items in the list show the default closed status without backfilling

Scenario 2: Implicit and Explicitly set default system status transitioned to custom status

  1. Fist set some of the work items explicitly to a system defined status.
  2. Create some custom statuses
project = Project.find(7) # flightjs/Flight
namespace = project.root_ancestor

open_status = WorkItems::Statuses::Custom::Status.create!(
  namespace: namespace,
  name: "Custom To do",
  color: "#737278",
  category: :to_do
)

in_progress_status = WorkItems::Statuses::Custom::Status.create!(
  namespace: namespace,
  name: "Custom In Progress",
  color: "#737278",
  category: :in_progress
)


in_review_status = WorkItems::Statuses::Custom::Status.create!(
  namespace: namespace,
  name: "Custom In Review",
  color: "#737278",
  category: :in_progress
)

closed_status = WorkItems::Statuses::Custom::Status.create!(
  namespace: namespace,
  name: "Custom done",
  color: "#108548",
  category: :done
)

no_do_status = WorkItems::Statuses::Custom::Status.create!(
  namespace: namespace,
  name: "Custom Won't do",
  color: "#108548",
  category: :in_progress
)

duplicate_status = WorkItems::Statuses::Custom::Status.create!(
  namespace: namespace,
  name: "Custom duplicate",
  color: "#DD2B0E",
  category: :cancelled
)

lifecycle = WorkItems::Statuses::Custom::Lifecycle.create!(
  namespace: namespace,
  name: "Default",
  default_open_status: open_status,
  default_closed_status: closed_status,
  default_duplicate_status: duplicate_status
)

task_type = WorkItems::Type.find_by(base_type: :task)

type_custom_lifecycle = WorkItems::TypeCustomLifecycle.create!(
  work_item_type: task_type,
  lifecycle: lifecycle
)

issue_type = WorkItems::Type.find_by(base_type: :issue)

type_custom_lifecycle = WorkItems::TypeCustomLifecycle.create!(
  work_item_type: issue_type,
  lifecycle: lifecycle
)

WorkItems::Statuses::Custom::LifecycleStatus.delete_all

WorkItems::Statuses::Custom::LifecycleStatus.create!([{
namespace: namespace,
lifecycle: lifecycle,
status: open_status,
position: 1
},
{
namespace: namespace,
lifecycle: lifecycle,
status: in_progress_status,
position: 2
},
{
namespace: namespace,
lifecycle: lifecycle,
status: in_review_status,
position: 3
},
{
namespace: namespace,
lifecycle: lifecycle,
status: closed_status,
position: 4
},
{
namespace: namespace,
lifecycle: lifecycle,
status: no_do_status,
position: 5
},
{
namespace: namespace,
lifecycle: lifecycle,
status: duplicate_status,
position: 6
}]
)
  1. Now Map the transition of system status to custom status
WorkItems::Statuses::Custom::TransitionMapping.create!(
  namespace: namespace, source_system_defined_status_id: 1, target_custom_status: open_status
)

WorkItems::Statuses::Custom::TransitionMapping.create!(
  namespace: namespace, source_system_defined_status_id: 2, target_custom_status: in_progress_status
)

WorkItems::Statuses::Custom::TransitionMapping.create!(
  namespace: namespace, source_system_defined_status_id: 3, target_custom_status: closed_status
)

WorkItems::Statuses::Custom::TransitionMapping.create!(
  namespace: namespace, source_system_defined_status_id: 4, target_custom_status: no_do_status
)

WorkItems::Statuses::Custom::TransitionMapping.create!(
  namespace: namespace, source_system_defined_status_id: 5, target_custom_status: duplicate_status
)

References

Screenshots or screen recordings

Before After

How to set up and validate locally

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Alexandru Croitor

Merge request reports

Loading