Skip to content

Commit

Permalink
Utility methods, UI enhancements, exported code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleu committed Nov 23, 2024
1 parent c3162e7 commit 66e04de
Show file tree
Hide file tree
Showing 67 changed files with 943 additions and 189 deletions.
6 changes: 6 additions & 0 deletions app/action/actionmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ func ActionFromMap(m util.ValueMap, setPK bool) (*Action, util.ValueMap, error)
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (a *Action) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "id", V: a.ID}, {K: "svc", V: a.Svc}, {K: "modelID", V: a.ModelID}, {K: "userID", V: a.UserID}, {K: "act", V: a.Act}, {K: "content", V: a.Content}, {K: "note", V: a.Note}, {K: "created", V: a.Created}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
12 changes: 12 additions & 0 deletions app/action/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ func (a Actions) GetByUserIDs(userIDs ...uuid.UUID) Actions {
})
}

func (a Actions) ToMaps() []util.ValueMap {
return lo.Map(a, func(x *Action, _ int) util.ValueMap {
return x.ToMap()
})
}

func (a Actions) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(a, func(x *Action, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (a Actions) ToCSV() ([]string, [][]string) {
return ActionFieldDescs.Keys(), lo.Map(a, func(x *Action, _ int) []string {
return x.Strings()
Expand Down
6 changes: 6 additions & 0 deletions app/comment/commentmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ func CommentFromMap(m util.ValueMap, setPK bool) (*Comment, util.ValueMap, error
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (c *Comment) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "id", V: c.ID}, {K: "svc", V: c.Svc}, {K: "modelID", V: c.ModelID}, {K: "userID", V: c.UserID}, {K: "content", V: c.Content}, {K: "html", V: c.HTML}, {K: "created", V: c.Created}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
12 changes: 12 additions & 0 deletions app/comment/comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ func (c Comments) GetByUserIDs(userIDs ...uuid.UUID) Comments {
})
}

func (c Comments) ToMaps() []util.ValueMap {
return lo.Map(c, func(x *Comment, _ int) util.ValueMap {
return x.ToMap()
})
}

func (c Comments) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(c, func(x *Comment, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (c Comments) ToCSV() ([]string, [][]string) {
return CommentFieldDescs.Keys(), lo.Map(c, func(x *Comment, _ int) []string {
return x.Strings()
Expand Down
6 changes: 6 additions & 0 deletions app/email/emailmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ func EmailFromMap(m util.ValueMap, setPK bool) (*Email, util.ValueMap, error) {
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (e *Email) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "id", V: e.ID}, {K: "recipients", V: e.Recipients}, {K: "subject", V: e.Subject}, {K: "data", V: e.Data}, {K: "plain", V: e.Plain}, {K: "html", V: e.HTML}, {K: "userID", V: e.UserID}, {K: "status", V: e.Status}, {K: "created", V: e.Created}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
12 changes: 12 additions & 0 deletions app/email/emails.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ func (e Emails) GetByUserIDs(userIDs ...uuid.UUID) Emails {
})
}

func (e Emails) ToMaps() []util.ValueMap {
return lo.Map(e, func(x *Email, _ int) util.ValueMap {
return x.ToMap()
})
}

func (e Emails) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(e, func(x *Email, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (e Emails) ToCSV() ([]string, [][]string) {
return EmailFieldDescs.Keys(), lo.Map(e, func(x *Email, _ int) []string {
return x.Strings()
Expand Down
12 changes: 12 additions & 0 deletions app/estimate/ehistory/estimatehistories.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ func (e EstimateHistories) GetByEstimateIDs(estimateIDs ...uuid.UUID) EstimateHi
})
}

func (e EstimateHistories) ToMaps() []util.ValueMap {
return lo.Map(e, func(x *EstimateHistory, _ int) util.ValueMap {
return x.ToMap()
})
}

func (e EstimateHistories) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(e, func(x *EstimateHistory, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (e EstimateHistories) ToCSV() ([]string, [][]string) {
return EstimateHistoryFieldDescs.Keys(), lo.Map(e, func(x *EstimateHistory, _ int) []string {
return x.Strings()
Expand Down
6 changes: 6 additions & 0 deletions app/estimate/ehistory/estimatehistorymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ func EstimateHistoryFromMap(m util.ValueMap, setPK bool) (*EstimateHistory, util
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (e *EstimateHistory) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "slug", V: e.Slug}, {K: "estimateID", V: e.EstimateID}, {K: "estimateName", V: e.EstimateName}, {K: "created", V: e.Created}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
6 changes: 6 additions & 0 deletions app/estimate/emember/estimatemembermap.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ func EstimateMemberFromMap(m util.ValueMap, setPK bool) (*EstimateMember, util.V
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (e *EstimateMember) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "estimateID", V: e.EstimateID}, {K: "userID", V: e.UserID}, {K: "name", V: e.Name}, {K: "picture", V: e.Picture}, {K: "role", V: e.Role}, {K: "created", V: e.Created}, {K: "updated", V: e.Updated}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
12 changes: 12 additions & 0 deletions app/estimate/emember/estimatemembers.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ func (e EstimateMembers) GetByUserIDs(userIDs ...uuid.UUID) EstimateMembers {
})
}

func (e EstimateMembers) ToMaps() []util.ValueMap {
return lo.Map(e, func(x *EstimateMember, _ int) util.ValueMap {
return x.ToMap()
})
}

func (e EstimateMembers) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(e, func(x *EstimateMember, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (e EstimateMembers) ToCSV() ([]string, [][]string) {
return EstimateMemberFieldDescs.Keys(), lo.Map(e, func(x *EstimateMember, _ int) []string {
return x.Strings()
Expand Down
6 changes: 6 additions & 0 deletions app/estimate/epermission/estimatepermissionmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ func EstimatePermissionFromMap(m util.ValueMap, setPK bool) (*EstimatePermission
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (e *EstimatePermission) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "estimateID", V: e.EstimateID}, {K: "key", V: e.Key}, {K: "value", V: e.Value}, {K: "access", V: e.Access}, {K: "created", V: e.Created}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
12 changes: 12 additions & 0 deletions app/estimate/epermission/estimatepermissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ func (e EstimatePermissions) GetByValues(values ...string) EstimatePermissions {
})
}

func (e EstimatePermissions) ToMaps() []util.ValueMap {
return lo.Map(e, func(x *EstimatePermission, _ int) util.ValueMap {
return x.ToMap()
})
}

func (e EstimatePermissions) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(e, func(x *EstimatePermission, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (e EstimatePermissions) ToCSV() ([]string, [][]string) {
return EstimatePermissionFieldDescs.Keys(), lo.Map(e, func(x *EstimatePermission, _ int) []string {
return x.Strings()
Expand Down
6 changes: 6 additions & 0 deletions app/estimate/estimatemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ func EstimateFromMap(m util.ValueMap, setPK bool) (*Estimate, util.ValueMap, err
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (e *Estimate) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "id", V: e.ID}, {K: "slug", V: e.Slug}, {K: "title", V: e.Title}, {K: "icon", V: e.Icon}, {K: "status", V: e.Status}, {K: "teamID", V: e.TeamID}, {K: "sprintID", V: e.SprintID}, {K: "choices", V: e.Choices}, {K: "created", V: e.Created}, {K: "updated", V: e.Updated}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
12 changes: 12 additions & 0 deletions app/estimate/estimates.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ func (e Estimates) GetBySprintIDs(sprintIDs ...*uuid.UUID) Estimates {
})
}

func (e Estimates) ToMaps() []util.ValueMap {
return lo.Map(e, func(x *Estimate, _ int) util.ValueMap {
return x.ToMap()
})
}

func (e Estimates) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(e, func(x *Estimate, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (e Estimates) ToCSV() ([]string, [][]string) {
return EstimateFieldDescs.Keys(), lo.Map(e, func(x *Estimate, _ int) []string {
return x.Strings()
Expand Down
12 changes: 12 additions & 0 deletions app/estimate/story/stories.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ func (s Stories) GetByUserIDs(userIDs ...uuid.UUID) Stories {
})
}

func (s Stories) ToMaps() []util.ValueMap {
return lo.Map(s, func(x *Story, _ int) util.ValueMap {
return x.ToMap()
})
}

func (s Stories) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(s, func(x *Story, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (s Stories) ToCSV() ([]string, [][]string) {
return StoryFieldDescs.Keys(), lo.Map(s, func(x *Story, _ int) []string {
return x.Strings()
Expand Down
6 changes: 6 additions & 0 deletions app/estimate/story/storymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ func StoryFromMap(m util.ValueMap, setPK bool) (*Story, util.ValueMap, error) {
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (s *Story) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "id", V: s.ID}, {K: "estimateID", V: s.EstimateID}, {K: "idx", V: s.Idx}, {K: "userID", V: s.UserID}, {K: "title", V: s.Title}, {K: "status", V: s.Status}, {K: "finalVote", V: s.FinalVote}, {K: "created", V: s.Created}, {K: "updated", V: s.Updated}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
6 changes: 6 additions & 0 deletions app/estimate/story/vote/votemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ func VoteFromMap(m util.ValueMap, setPK bool) (*Vote, util.ValueMap, error) {
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (v *Vote) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "storyID", V: v.StoryID}, {K: "userID", V: v.UserID}, {K: "choice", V: v.Choice}, {K: "created", V: v.Created}, {K: "updated", V: v.Updated}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
12 changes: 12 additions & 0 deletions app/estimate/story/vote/votes.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ func (v Votes) GetByUserIDs(userIDs ...uuid.UUID) Votes {
})
}

func (v Votes) ToMaps() []util.ValueMap {
return lo.Map(v, func(x *Vote, _ int) util.ValueMap {
return x.ToMap()
})
}

func (v Votes) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(v, func(x *Vote, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (v Votes) ToCSV() ([]string, [][]string) {
return VoteFieldDescs.Keys(), lo.Map(v, func(x *Vote, _ int) []string {
return x.Strings()
Expand Down
2 changes: 1 addition & 1 deletion app/lib/filesystem/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (f *FileSystem) UnzipToDir(src string, dest string) (*util.OrderedMap[int64
if err != nil {
return nil, err
}
ret.Append(f.Name, fsz)
ret.Set(f.Name, fsz)
}
return ret, nil
}
6 changes: 6 additions & 0 deletions app/retro/feedback/feedbackmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ func FeedbackFromMap(m util.ValueMap, setPK bool) (*Feedback, util.ValueMap, err
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (f *Feedback) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "id", V: f.ID}, {K: "retroID", V: f.RetroID}, {K: "idx", V: f.Idx}, {K: "userID", V: f.UserID}, {K: "category", V: f.Category}, {K: "content", V: f.Content}, {K: "html", V: f.HTML}, {K: "created", V: f.Created}, {K: "updated", V: f.Updated}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
12 changes: 12 additions & 0 deletions app/retro/feedback/feedbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ func (f Feedbacks) GetByUserIDs(userIDs ...uuid.UUID) Feedbacks {
})
}

func (f Feedbacks) ToMaps() []util.ValueMap {
return lo.Map(f, func(x *Feedback, _ int) util.ValueMap {
return x.ToMap()
})
}

func (f Feedbacks) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(f, func(x *Feedback, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (f Feedbacks) ToCSV() ([]string, [][]string) {
return FeedbackFieldDescs.Keys(), lo.Map(f, func(x *Feedback, _ int) []string {
return x.Strings()
Expand Down
6 changes: 6 additions & 0 deletions app/retro/retromap.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ func RetroFromMap(m util.ValueMap, setPK bool) (*Retro, util.ValueMap, error) {
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (r *Retro) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "id", V: r.ID}, {K: "slug", V: r.Slug}, {K: "title", V: r.Title}, {K: "icon", V: r.Icon}, {K: "status", V: r.Status}, {K: "teamID", V: r.TeamID}, {K: "sprintID", V: r.SprintID}, {K: "categories", V: r.Categories}, {K: "created", V: r.Created}, {K: "updated", V: r.Updated}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
12 changes: 12 additions & 0 deletions app/retro/retros.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ func (r Retros) GetBySprintIDs(sprintIDs ...*uuid.UUID) Retros {
})
}

func (r Retros) ToMaps() []util.ValueMap {
return lo.Map(r, func(x *Retro, _ int) util.ValueMap {
return x.ToMap()
})
}

func (r Retros) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(r, func(x *Retro, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (r Retros) ToCSV() ([]string, [][]string) {
return RetroFieldDescs.Keys(), lo.Map(r, func(x *Retro, _ int) []string {
return x.Strings()
Expand Down
12 changes: 12 additions & 0 deletions app/retro/rhistory/retrohistories.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ func (r RetroHistories) GetByRetroIDs(retroIDs ...uuid.UUID) RetroHistories {
})
}

func (r RetroHistories) ToMaps() []util.ValueMap {
return lo.Map(r, func(x *RetroHistory, _ int) util.ValueMap {
return x.ToMap()
})
}

func (r RetroHistories) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(r, func(x *RetroHistory, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (r RetroHistories) ToCSV() ([]string, [][]string) {
return RetroHistoryFieldDescs.Keys(), lo.Map(r, func(x *RetroHistory, _ int) []string {
return x.Strings()
Expand Down
5 changes: 5 additions & 0 deletions app/retro/rhistory/retrohistorymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ func RetroHistoryFromMap(m util.ValueMap, setPK bool) (*RetroHistory, util.Value
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

func (r *RetroHistory) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "slug", V: r.Slug}, {K: "retroID", V: r.RetroID}, {K: "retroName", V: r.RetroName}, {K: "created", V: r.Created}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
6 changes: 6 additions & 0 deletions app/retro/rmember/retromembermap.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ func RetroMemberFromMap(m util.ValueMap, setPK bool) (*RetroMember, util.ValueMa
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (r *RetroMember) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "retroID", V: r.RetroID}, {K: "userID", V: r.UserID}, {K: "name", V: r.Name}, {K: "picture", V: r.Picture}, {K: "role", V: r.Role}, {K: "created", V: r.Created}, {K: "updated", V: r.Updated}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
12 changes: 12 additions & 0 deletions app/retro/rmember/retromembers.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ func (r RetroMembers) GetByUserIDs(userIDs ...uuid.UUID) RetroMembers {
})
}

func (r RetroMembers) ToMaps() []util.ValueMap {
return lo.Map(r, func(x *RetroMember, _ int) util.ValueMap {
return x.ToMap()
})
}

func (r RetroMembers) ToOrderedMaps() util.OrderedMaps[any] {
return lo.Map(r, func(x *RetroMember, _ int) *util.OrderedMap[any] {
return x.ToOrderedMap()
})
}

func (r RetroMembers) ToCSV() ([]string, [][]string) {
return RetroMemberFieldDescs.Keys(), lo.Map(r, func(x *RetroMember, _ int) []string {
return x.Strings()
Expand Down
6 changes: 6 additions & 0 deletions app/retro/rpermission/retropermissionmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ func RetroPermissionFromMap(m util.ValueMap, setPK bool) (*RetroPermission, util
// $PF_SECTION_END(extrachecks)$
return ret, extra, nil
}

//nolint:lll
func (r *RetroPermission) ToOrderedMap() *util.OrderedMap[any] {
pairs := util.OrderedPairs[any]{{K: "retroID", V: r.RetroID}, {K: "key", V: r.Key}, {K: "value", V: r.Value}, {K: "access", V: r.Access}, {K: "created", V: r.Created}}
return util.NewOrderedMap[any](false, 4, pairs...)
}
Loading

0 comments on commit 66e04de

Please sign in to comment.