Skip to content

Commit

Permalink
[NOREF] Split create milestone mutation (#1517)
Browse files Browse the repository at this point in the history
* feat: Split single resolver for creating milestones into 2 resolvers for creating custom and common milestones

* Update postman collection and code comments

* Missed comment
  • Loading branch information
ClayBenson94 authored Nov 13, 2024
1 parent 2b9676b commit c936986
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 59 deletions.
12 changes: 6 additions & 6 deletions MINT.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -2996,13 +2996,13 @@
"name": "Milestones",
"item": [
{
"name": "NewMTOMilestone",
"name": "NewMTOMilestone (Custom)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"let responseData = pm.response.json().data.createMTOMilestone",
"let responseData = pm.response.json().data.createMTOMilestoneCustom",
"",
"mtoMilestoneID = responseData.id",
"",
Expand All @@ -3020,7 +3020,7 @@
"body": {
"mode": "graphql",
"graphql": {
"query": "mutation NewMTOMilestone {\ncreateMTOMilestone(modelPlanID: \"{{modelPlanID}}\",\nname: \"Uncategorized milestone\"\n# commonMilestoneKey: MILESTONE_A\n# ,mtoCategoryID: \"{{mtoCategoryID}}\"\n# ,mtoCategoryID: \"{{mtoSubcategoryID}}\"\n) {\n id\n name\n addedFromMilestoneLibrary\n facilitatedBy\n needBy\n status\n riskIndicator\n # isDraftMilestone\n mtoCategoryID\n key\n\n # commonMilestone\n # solutions\n # category\n # subCategory\n }\n}",
"query": "mutation NewMTOMilestone {\n createMTOMilestoneCustom(modelPlanID: \"{{modelPlanID}}\",\n name: \"Uncategorized milestone\"\n # mtoCategoryID: \"\"\n) {\n id\n name\n addedFromMilestoneLibrary\n facilitatedBy\n needBy\n status\n riskIndicator\n # isDraftMilestone\n mtoCategoryID\n key\n\n # commonMilestone\n # solutions\n # category\n # subCategory\n }\n}",
"variables": ""
}
},
Expand All @@ -3034,13 +3034,13 @@
"response": []
},
{
"name": "NewMTOMilestone From Common Milestone",
"name": "NewMTOMilestone (Common)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"let responseData = pm.response.json().data.createMTOMilestone",
"let responseData = pm.response.json().data.createMTOMilestoneCommon",
"",
"mtoMilestoneID = responseData.id",
"",
Expand All @@ -3058,7 +3058,7 @@
"body": {
"mode": "graphql",
"graphql": {
"query": "mutation NewMTOMilestone {\ncreateMTOMilestone(modelPlanID: \"{{modelPlanID}}\",\n# name: \"Uncategorized commonMilestone \"\ncommonMilestoneKey: MILESTONE_A\n# ,mtoCategoryID: \"{{mtoCategoryID}}\"\n# ,mtoCategoryID: \"{{mtoSubcategoryID}}\"\n) {\n id\n name\n key\n addedFromMilestoneLibrary\n facilitatedBy\n needBy\n status\n riskIndicator\n # isDraftMilestone\n mtoCategoryID\n\n # commonMilestone\n # solutions\n # category\n # subCategory\n }\n}",
"query": "mutation NewMTOMilestone {\n createMTOMilestoneCommon(modelPlanID: \"{{modelPlanID}}\",\n commonMilestoneKey: MILESTONE_A\n) {\n id\n name\n key\n addedFromMilestoneLibrary\n facilitatedBy\n needBy\n status\n riskIndicator\n # isDraftMilestone\n mtoCategoryID\n\n # commonMilestone\n # solutions\n # category\n # subCategory\n }\n}",
"variables": ""
}
},
Expand Down
16 changes: 8 additions & 8 deletions cmd/dbseed/mto.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/google/uuid"

"github.com/cms-enterprise/mint-app/pkg/graph/resolvers"
"github.com/cms-enterprise/mint-app/pkg/helpers"
"github.com/cms-enterprise/mint-app/pkg/models"
)

Expand All @@ -19,7 +18,8 @@ func (s *Seeder) seedModelPlanWithMTOData(
princ := s.getTestPrincipalByUsername(euaID)

// Make uncategorized Milestone from Common milestone library
_, err := resolvers.MTOMilestoneCreate(s.Config.Context, s.Config.Logger, princ, s.Config.Store, nil, helpers.PointerTo(models.MTOCommonMilestoneKeyMilestoneA), plan.ID, nil)
// TODO: This likely won't be uncategorized anymore once common milestones also create categories as needed
_, err := resolvers.MTOMilestoneCreateCommon(s.Config.Context, s.Config.Logger, princ, s.Config.Store, plan.ID, models.MTOCommonMilestoneKeyMilestoneA)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -62,29 +62,29 @@ func (s *Seeder) seedModelPlanWithMTOData(
}

// Make milestones to go under the categories
_, err = resolvers.MTOMilestoneCreate(s.Config.Context, s.Config.Logger, princ, s.Config.Store, helpers.PointerTo("Milestone"+cat1Name), nil, plan.ID, &category1.ID)
_, err = resolvers.MTOMilestoneCreateCustom(s.Config.Context, s.Config.Logger, princ, s.Config.Store, "Milestone"+cat1Name, plan.ID, &category1.ID)
if err != nil {
panic(err)
}
_, err = resolvers.MTOMilestoneCreate(s.Config.Context, s.Config.Logger, princ, s.Config.Store, helpers.PointerTo("Milestone"+cat1SubAName), nil, plan.ID, &category1SubA.ID)
_, err = resolvers.MTOMilestoneCreateCustom(s.Config.Context, s.Config.Logger, princ, s.Config.Store, "Milestone"+cat1SubAName, plan.ID, &category1SubA.ID)
if err != nil {
panic(err)
}
_, err = resolvers.MTOMilestoneCreate(s.Config.Context, s.Config.Logger, princ, s.Config.Store, helpers.PointerTo("Milestone"+cat1SubBName), nil, plan.ID, &category1SubB.ID)
_, err = resolvers.MTOMilestoneCreateCustom(s.Config.Context, s.Config.Logger, princ, s.Config.Store, "Milestone"+cat1SubBName, plan.ID, &category1SubB.ID)
if err != nil {
panic(err)
}

// Make milestones to go under the categories
_, err = resolvers.MTOMilestoneCreate(s.Config.Context, s.Config.Logger, princ, s.Config.Store, helpers.PointerTo("Milestone"+cat2Name), nil, plan.ID, &category2.ID)
_, err = resolvers.MTOMilestoneCreateCustom(s.Config.Context, s.Config.Logger, princ, s.Config.Store, "Milestone"+cat2Name, plan.ID, &category2.ID)
if err != nil {
panic(err)
}
_, err = resolvers.MTOMilestoneCreate(s.Config.Context, s.Config.Logger, princ, s.Config.Store, helpers.PointerTo("Milestone"+cat2SubAName), nil, plan.ID, &category2SubA.ID)
_, err = resolvers.MTOMilestoneCreateCustom(s.Config.Context, s.Config.Logger, princ, s.Config.Store, "Milestone"+cat2SubAName, plan.ID, &category2SubA.ID)
if err != nil {
panic(err)
}
_, err = resolvers.MTOMilestoneCreate(s.Config.Context, s.Config.Logger, princ, s.Config.Store, helpers.PointerTo("Milestone"+cat2SubBName), nil, plan.ID, &category2SubB.ID)
_, err = resolvers.MTOMilestoneCreateCustom(s.Config.Context, s.Config.Logger, princ, s.Config.Store, "Milestone"+cat2SubBName, plan.ID, &category2SubB.ID)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions migrations/V182__Add_MTO_Common_Milestone.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ CREATE TABLE mto_common_milestone (
key MTO_COMMON_MILESTONE_KEY NOT NULL PRIMARY KEY,
name ZERO_STRING NOT NULL,

category_name ZERO_STRING NOT NULL,
sub_category_name ZERO_STRING NOT NULL,
category_name ZERO_STRING NOT NULL, -- TODO: Revisit if this should be NOT NULL
sub_category_name ZERO_STRING NOT NULL, -- TODO: Revisit if this should be NOT NULL, and if common milestones _actually_ have subCategories
description ZERO_STRING NOT NULL, -- TODO (mto) is this needed?
facilitated_by_role MTO_FACILITATOR NOT NULL
);
Expand Down
Loading

0 comments on commit c936986

Please sign in to comment.