Skip to content

Commit

Permalink
Addresses Review Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gbdubs committed Dec 19, 2023
1 parent 7200460 commit 037e32b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions cmd/server/pactasrv/conv/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ func ptr[T any](t T) *T {
return &t
}

func strPtr[T ~string](t T) *string {
return ptr(string(t))
}

func ifNil[T any](t *T, fallback T) T {
if t == nil {
return fallback
Expand Down
8 changes: 4 additions & 4 deletions cmd/server/pactasrv/conv/pacta_to_oapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func InitiativeToOAPI(i *pacta.Initiative) (*api.Initiative, error) {
IsAcceptingNewPortfolios: i.IsAcceptingNewPortfolios,
Language: api.InitiativeLanguage(i.Language),
Name: i.Name,
PactaVersion: ptr(string(i.PACTAVersion.ID)),
PactaVersion: strPtr(i.PACTAVersion.ID),
PublicDescription: i.PublicDescription,
RequiresInvitationToJoin: i.RequiresInvitationToJoin,
PortfolioInitiativeMemberships: pims,
Expand All @@ -37,7 +37,7 @@ func portfolioInitiativeMembershipToOAPIPortfolio(in *pacta.PortfolioInitiativeM
CreatedAt: in.CreatedAt,
}
if in.AddedBy != nil && in.AddedBy.ID == "" {
out.AddedByUserId = ptr(string(in.AddedBy.ID))
out.AddedByUserId = strPtr(in.AddedBy.ID)
}
p, err := PortfolioToOAPI(in.Portfolio)
if err != nil {
Expand All @@ -53,7 +53,7 @@ func portfolioInitiativeMembershipToOAPIInitiative(in *pacta.PortfolioInitiative
CreatedAt: in.CreatedAt,
}
if in.AddedBy != nil && in.AddedBy.ID == "" {
out.AddedByUserId = ptr(string(in.AddedBy.ID))
out.AddedByUserId = strPtr(in.AddedBy.ID)
}
if in.Initiative != nil {
i, err := InitiativeToOAPI(in.Initiative)
Expand Down Expand Up @@ -104,7 +104,7 @@ func InitiativeInvitationToOAPI(i *pacta.InitiativeInvitation) (*api.InitiativeI
}
var usedBy *string
if i.UsedBy != nil {
usedBy = ptr(string(i.UsedBy.ID))
usedBy = strPtr(i.UsedBy.ID)
}
return &api.InitiativeInvitation{
CreatedAt: i.CreatedAt,
Expand Down

0 comments on commit 037e32b

Please sign in to comment.