Skip to content

JH Epic support milestone and iteration in new page

What does this MR do and why?

Related issue: #3836 (comment 4330015)

License: Premium. FF, Self-Manage

Changelog: added

Feature flag is: epic_support_milestone_and_iteration, The rollout issue: #4049

Advice of JH Database development

Naming guideline

  1. Database table naming always use jh_ prefix

    1. If it is a upstream table' extend, then name it as jh_xxxx_extends
    2. If it is a JH only table, then name it as jh_xxxx
  2. Model file path and naming

    1. If it is a JH only database model, we should place it always under the jh/app/models/xxx/ folder, and use the definition form like below:
      # path: jh/app/models/extend/milestone.rb
      module Extend
        class Milestone < JH::ApplicationRecord
          # xxxx
        end
      end
    2. If it is a Upstream model override module, we should place it always under the jh/app/models/jh/ folder, and use the definition form like below:
      # path: jh/app/models/jh/milestone.rb
      module JH
        module Milestone
          extend ActiveSupport::Concern
          extend ::Gitlab::Utils::Override
      
          # xxxx
        end
      end
  3. Model relationship naming

    1. If it is a JH model of a database extend table(such as jh_milestone_extends), its relationship name should always excludes the _extends suffix to make its meaning more clearer for code reading. such as the jh_milestone string below:

      module JH
        module Milestone
          prepended do
            has_one :jh_milestone, class_name: 'Extend::Milestone'
          end
        end
      end
      
      # Then we can use the clearer naming method:
      upstream_milestone = Milestone.last
      upstream_milestone.jh_milestone # => Get data in the Jh extend table

How to set up and validate locally

  1. Copy jh/config/database.yml.example contents into config/database.yml, modify it to fit your local development env.

  2. RESTART GDK!

  3. Run bundle exec rails db:create:jh to create JH database

  4. Run bundle exec rails db:migrate:jh to perform the migrations, it should create jh_epic_extends jh_milestone_extends jh_sprint_extends three tables

  5. Enable the feature flag in the rails console using ::Feature.enable(:epic_support_milestone_and_iteration)

  6. Use curl to request the graphql API like below:

    curl --location 'http://gdk.test:3000/api/graphql' \
    --header 'PRIVATE-TOKEN: <TOKEN>' \
    --header 'Content-Type: application/json' \
    --data '{"query":"mutation createEpic($input: CreateEpicInput!) {\n  createEpic(input: $input) {\n    epic {\n      id\n      webUrl\n      __typename\n    }\n    errors\n    __typename\n  }\n}","variables":{"input":{"addLabelIds":[],"groupPath":"tragedxy","title":"xyz 789","description":"Just a xyz test","confidential":false,"startDateFixed":"2024-03-01","startDateIsFixed":true,"dueDateFixed":"2024-04-05","dueDateIsFixed":true,"milestoneId":60,"sprintId":41109}}}'
  7. The response should be like this when create epic successfully:

    {
      "data": {
        "createEpic": {
          "epic": {
            "id": "gid://gitlab/Epic/82",
            "webUrl": "http://gdk.test:3000/groups/tragedxy/-/epics/42",
            "__typename": "Epic"
          },
          "errors": [],
          "__typename": "CreateEpicPayload"
        }
      }
    }
  8. Then could enter the rails console to check the created records in JH extend tables:

    ue = Epic.last
    je = ue.jh_epic
    
    jm = je.jh_milestone
    um = jm.milestone
    
    ji = je.jh_iteration
    ui = ji.iteration
xfyuan 编辑于

合并请求报告

加载中