Skip to content

Commit

Permalink
feat: address feedback around comments and naming
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenWadeOddball committed Dec 3, 2024
1 parent ac351ef commit 06fcd85
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 31 deletions.
14 changes: 4 additions & 10 deletions pkg/graph/generated/generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -17129,8 +17129,6 @@ type MTOMilestone {
solutions: [MTOSolution!]!
"""
Category resolves relational category information.
if a milestone is uncategorized, this struct will still return
it will have a null value for both
"""
categories: MTOCategories!
}
Expand Down Expand Up @@ -31301,9 +31299,9 @@ func (ec *executionContext) _MTOCategories_category(ctx context.Context, field g
}
return graphql.Null
}
res := resTmp.(models.MTOCategory)
res := resTmp.(*models.MTOCategory)
fc.Result = res
return ec.marshalNMTOCategory2githubᚗcomᚋcmsᚑenterpriseᚋmintᚑappᚋpkgᚋmodelsᚐMTOCategory(ctx, field.Selections, res)
return ec.marshalNMTOCategory2ᚖgithubᚗcomᚋcmsᚑenterpriseᚋmintᚑappᚋpkgᚋmodelsᚐMTOCategory(ctx, field.Selections, res)
}

func (ec *executionContext) fieldContext_MTOCategories_category(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
Expand Down Expand Up @@ -31357,9 +31355,9 @@ func (ec *executionContext) _MTOCategories_subCategory(ctx context.Context, fiel
}
return graphql.Null
}
res := resTmp.(models.MTOSubcategory)
res := resTmp.(*models.MTOSubcategory)
fc.Result = res
return ec.marshalNMTOSubcategory2githubᚗcomᚋcmsᚑenterpriseᚋmintᚑappᚋpkgᚋmodelsᚐMTOSubcategory(ctx, field.Selections, res)
return ec.marshalNMTOSubcategory2ᚖgithubᚗcomᚋcmsᚑenterpriseᚋmintᚑappᚋpkgᚋmodelsᚐMTOSubcategory(ctx, field.Selections, res)
}

func (ec *executionContext) fieldContext_MTOCategories_subCategory(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
Expand Down Expand Up @@ -156558,10 +156556,6 @@ func (ec *executionContext) marshalNMTOStatus2githubᚗcomᚋcmsᚑenterpriseᚋ
return res
}

func (ec *executionContext) marshalNMTOSubcategory2githubᚗcomᚋcmsᚑenterpriseᚋmintᚑappᚋpkgᚋmodelsᚐMTOSubcategory(ctx context.Context, sel ast.SelectionSet, v models.MTOSubcategory) graphql.Marshaler {
return ec._MTOSubcategory(ctx, sel, &v)
}

func (ec *executionContext) marshalNMTOSubcategory2ᚕᚖgithubᚗcomᚋcmsᚑenterpriseᚋmintᚑappᚋpkgᚋmodelsᚐMTOSubcategoryᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.MTOSubcategory) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
Expand Down
10 changes: 5 additions & 5 deletions pkg/graph/resolvers/mto_category.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ func MTOCategoryGetByID(ctx context.Context, id uuid.UUID) (*models.MTOCategory,
// We are not doing a larger SQL call that would return both objects, as that would result in less maintainable code
func MTOCategoriesGetByID(ctx context.Context, id *uuid.UUID, modelPlanID uuid.UUID) (*models.MTOCategories, error) {
Categories := &models.MTOCategories{
Category: *models.MTOUncategorized(modelPlanID, nil, 0),
SubCategory: *models.MTOUncategorizedSubcategory(modelPlanID, helpers.PointerTo(uuid.Nil), 0),
Category: models.MTOUncategorized(modelPlanID, nil, 0),
SubCategory: models.MTOUncategorizedSubcategory(modelPlanID, helpers.PointerTo(uuid.Nil), 0),
}
if id == nil {
return Categories, nil
Expand All @@ -163,7 +163,7 @@ func MTOCategoriesGetByID(ctx context.Context, id *uuid.UUID, modelPlanID uuid.U
}
// Check if it is a parent category, if so early return without fetching parent
if immediateCategory.ParentID == nil {
Categories.Category = *immediateCategory
Categories.Category = immediateCategory
return Categories, nil
}

Expand All @@ -172,8 +172,8 @@ func MTOCategoriesGetByID(ctx context.Context, id *uuid.UUID, modelPlanID uuid.U
if err != nil {
return nil, err
}
Categories.SubCategory = *immediateCategory.ToSubcategory()
Categories.Category = *parentCategory
Categories.SubCategory = immediateCategory.ToSubcategory()
Categories.Category = parentCategory

return Categories, nil
}
2 changes: 0 additions & 2 deletions pkg/graph/schema/types/mto_milestone.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ type MTOMilestone {
solutions: [MTOSolution!]!
"""
Category resolves relational category information.
if a milestone is uncategorized, this struct will still return
it will have a null value for both
"""
categories: MTOCategories!
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/models/mto_category.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ type MTOCategory struct {
ParentID *uuid.UUID `json:"parent_id" db:"parent_id"`
}

// MTOCategories is a struct meant to represent the Category and Subcategory associated with a given MTO Milestone.
// This struct exists to allow us to resolve/fetch both Category and Subcategory at the same time and return them together in a single resolver.
type MTOCategories struct {
// TODO (mto) should these fields be pointers? Technically they should never be null
Category MTOCategory `json:"category,omitempty"`
SubCategory MTOSubcategory `json:"subCategory,omitempty"`
Category *MTOCategory `json:"category,omitempty"`
SubCategory *MTOSubcategory `json:"subCategory,omitempty"`
}

func (m MTOCategory) GetPosition() int {
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/loaders/mto_category.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func batchMTOCategoryGetByID(ctx context.Context, ids []uuid.UUID) []*dataloader
if err != nil {
return errorPerEachKey[uuid.UUID, *models.MTOCategory](ids, err)
}
data, err := storage.MTOCategoryGetByIDsLoader(loaders.DataReader.Store, logger, ids)
data, err := storage.MTOCategoryGetByIDLoader(loaders.DataReader.Store, logger, ids)
if err != nil {
return errorPerEachKey[uuid.UUID, *models.MTOCategory](ids, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/loaders/mto_milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func batchMTOMilestoneGetByID(ctx context.Context, ids []uuid.UUID) []*dataloade
if err != nil {
return errorPerEachKey[uuid.UUID, *models.MTOMilestone](ids, err)
}
data, err := storage.MTOMilestoneGetByIDsLoader(loaders.DataReader.Store, logger, ids)
data, err := storage.MTOMilestoneGetByIDLoader(loaders.DataReader.Store, logger, ids)
if err != nil {
return errorPerEachKey[uuid.UUID, *models.MTOMilestone](ids, err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/mto_category.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/cms-enterprise/mint-app/pkg/sqlutils"
)

// MTOCategoryGetByIDsLoader returns all categories by the provided
func MTOCategoryGetByIDsLoader(np sqlutils.NamedPreparer, _ *zap.Logger, ids []uuid.UUID) ([]*models.MTOCategory, error) {
// MTOCategoryGetByIDLoader returns all categories by the provided
func MTOCategoryGetByIDLoader(np sqlutils.NamedPreparer, _ *zap.Logger, ids []uuid.UUID) ([]*models.MTOCategory, error) {

args := map[string]interface{}{
"ids": pq.Array(ids),
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/mto_milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/cms-enterprise/mint-app/pkg/sqlutils"
)

// MTOMilestoneGetByIDsLoader returns all milestones by the provided ids
func MTOMilestoneGetByIDsLoader(np sqlutils.NamedPreparer, _ *zap.Logger, ids []uuid.UUID) ([]*models.MTOMilestone, error) {
// MTOMilestoneGetByIDLoader returns all milestones by the provided ids
func MTOMilestoneGetByIDLoader(np sqlutils.NamedPreparer, _ *zap.Logger, ids []uuid.UUID) ([]*models.MTOMilestone, error) {

args := map[string]interface{}{
"ids": pq.Array(ids),
Expand Down
6 changes: 1 addition & 5 deletions src/gql/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,7 @@ export type MtoInfoTranslation = {
export type MtoMilestone = {
__typename: 'MTOMilestone';
addedFromMilestoneLibrary: Scalars['Boolean']['output'];
/**
* Category resolves relational category information.
* if a milestone is uncategorized, this struct will still return
* it will have a null value for both
*/
/** Category resolves relational category information. */
categories: MtoCategories;
commonMilestone?: Maybe<MtoCommonMilestone>;
createdBy: Scalars['UUID']['output'];
Expand Down

0 comments on commit 06fcd85

Please sign in to comment.