Skip to content

Commit

Permalink
ToMap method in generated code, upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleu committed Oct 26, 2024
1 parent 1368df3 commit 02d1f46
Show file tree
Hide file tree
Showing 41 changed files with 223 additions and 21 deletions.
5 changes: 5 additions & 0 deletions app/action/actionmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/kyleu/rituals/app/util"
)

//nolint:lll
func (a *Action) ToMap() util.ValueMap {
return util.ValueMap{"id": a.ID, "svc": a.Svc, "modelID": a.ModelID, "userID": a.UserID, "act": a.Act, "content": a.Content, "note": a.Note, "created": a.Created}
}

//nolint:gocognit
func FromMap(m util.ValueMap, setPK bool) (*Action, util.ValueMap, error) {
ret := &Action{}
Expand Down
4 changes: 4 additions & 0 deletions app/comment/commentmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import (
"github.com/kyleu/rituals/app/util"
)

func (c *Comment) ToMap() util.ValueMap {
return util.ValueMap{"id": c.ID, "svc": c.Svc, "modelID": c.ModelID, "userID": c.UserID, "content": c.Content, "html": c.HTML, "created": c.Created}
}

//nolint:gocognit
func FromMap(m util.ValueMap, setPK bool) (*Comment, util.ValueMap, error) {
ret := &Comment{}
Expand Down
2 changes: 1 addition & 1 deletion app/controller/clib/databasesql.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func DatabaseSQLRun(w http.ResponseWriter, r *http.Request) {
defer func() { _ = tx.Rollback() }()

var columns []string
results := [][]any{}
var results [][]any

timer := util.TimerStart()
result, err := svc.Query(ps.Context, sql, tx, ps.Logger)
Expand Down
5 changes: 5 additions & 0 deletions app/email/emailmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ package email

import "github.com/kyleu/rituals/app/util"

//nolint:lll
func (e *Email) ToMap() util.ValueMap {
return util.ValueMap{"id": e.ID, "recipients": e.Recipients, "subject": e.Subject, "data": e.Data, "plain": e.Plain, "html": e.HTML, "userID": e.UserID, "status": e.Status, "created": e.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*Email, util.ValueMap, error) {
ret := &Email{}
extra := util.ValueMap{}
Expand Down
6 changes: 5 additions & 1 deletion app/enum/memberstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ type MemberStatus struct {
}

func (m MemberStatus) String() string {
return m.Key
}

func (m MemberStatus) NameSafe() string {
if m.Name != "" {
return m.Name
}
return m.Key
return m.String()
}

func (m MemberStatus) Matches(xx MemberStatus) bool {
Expand Down
6 changes: 5 additions & 1 deletion app/enum/modelservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ type ModelService struct {
}

func (m ModelService) String() string {
return m.Key
}

func (m ModelService) NameSafe() string {
if m.Name != "" {
return m.Name
}
return m.Key
return m.String()
}

func (m ModelService) Matches(xx ModelService) bool {
Expand Down
6 changes: 5 additions & 1 deletion app/enum/sessionstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ type SessionStatus struct {
}

func (s SessionStatus) String() string {
return s.Key
}

func (s SessionStatus) NameSafe() string {
if s.Name != "" {
return s.Name
}
return s.Key
return s.String()
}

func (s SessionStatus) Matches(xx SessionStatus) bool {
Expand Down
4 changes: 4 additions & 0 deletions app/estimate/ehistory/estimatehistorymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package ehistory

import "github.com/kyleu/rituals/app/util"

func (e *EstimateHistory) ToMap() util.ValueMap {
return util.ValueMap{"slug": e.Slug, "estimateID": e.EstimateID, "estimateName": e.EstimateName, "created": e.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*EstimateHistory, util.ValueMap, error) {
ret := &EstimateHistory{}
extra := util.ValueMap{}
Expand Down
5 changes: 5 additions & 0 deletions app/estimate/emember/estimatemembermap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/kyleu/rituals/app/util"
)

//nolint:lll
func (e *EstimateMember) ToMap() util.ValueMap {
return util.ValueMap{"estimateID": e.EstimateID, "userID": e.UserID, "name": e.Name, "picture": e.Picture, "role": e.Role, "created": e.Created, "updated": e.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*EstimateMember, util.ValueMap, error) {
ret := &EstimateMember{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/estimate/epermission/estimatepermissionmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package epermission

import "github.com/kyleu/rituals/app/util"

func (e *EstimatePermission) ToMap() util.ValueMap {
return util.ValueMap{"estimateID": e.EstimateID, "key": e.Key, "value": e.Value, "access": e.Access, "created": e.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*EstimatePermission, util.ValueMap, error) {
ret := &EstimatePermission{}
extra := util.ValueMap{}
Expand Down
5 changes: 5 additions & 0 deletions app/estimate/estimatemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/kyleu/rituals/app/util"
)

//nolint:lll
func (e *Estimate) ToMap() util.ValueMap {
return util.ValueMap{"id": e.ID, "slug": e.Slug, "title": e.Title, "icon": e.Icon, "status": e.Status, "teamID": e.TeamID, "sprintID": e.SprintID, "choices": e.Choices, "created": e.Created, "updated": e.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*Estimate, util.ValueMap, error) {
ret := &Estimate{}
extra := util.ValueMap{}
Expand Down
5 changes: 5 additions & 0 deletions app/estimate/story/storymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/kyleu/rituals/app/util"
)

//nolint:lll
func (s *Story) ToMap() util.ValueMap {
return util.ValueMap{"id": s.ID, "estimateID": s.EstimateID, "idx": s.Idx, "userID": s.UserID, "title": s.Title, "status": s.Status, "finalVote": s.FinalVote, "created": s.Created, "updated": s.Updated}
}

//nolint:gocognit
func FromMap(m util.ValueMap, setPK bool) (*Story, util.ValueMap, error) {
ret := &Story{}
Expand Down
4 changes: 4 additions & 0 deletions app/estimate/story/vote/votemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package vote

import "github.com/kyleu/rituals/app/util"

func (v *Vote) ToMap() util.ValueMap {
return util.ValueMap{"storyID": v.StoryID, "userID": v.UserID, "choice": v.Choice, "created": v.Created, "updated": v.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*Vote, util.ValueMap, error) {
ret := &Vote{}
extra := util.ValueMap{}
Expand Down
9 changes: 5 additions & 4 deletions app/lib/database/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ func (s *DebugStatement) Complete(count int, msg string, err error, output ...an
type DebugStatements []*DebugStatement

func (d DebugStatements) Add(st *DebugStatement) DebugStatements {
if len(d) > MaxTracedStatements {
d = d[1:]
x := d[:]
if len(x) > MaxTracedStatements {
x = x[1:]
}
d = append(d, st)
return d
x = append(x, st)
return x
}

func GetDebugStatements(key string) DebugStatements {
Expand Down
4 changes: 2 additions & 2 deletions app/lib/database/migrate/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ func newMigration(ctx context.Context, s *database.Service, e *Migration, tx *sq

func maxMigrationIdx(ctx context.Context, s *database.Service, tx *sqlx.Tx, logger util.Logger) int {
q := database.SQLSelectSimple("max(idx) as x", "migration", s.Type)
max, err := s.SingleInt(ctx, q, tx, logger)
mx, err := s.SingleInt(ctx, q, tx, logger)
if err != nil {
logger.Errorf("error getting migrations: %+v", err)
return -1
}
return int(max)
return int(mx)
}
5 changes: 5 additions & 0 deletions app/retro/feedback/feedbackmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ package feedback

import "github.com/kyleu/rituals/app/util"

//nolint:lll
func (f *Feedback) ToMap() util.ValueMap {
return util.ValueMap{"id": f.ID, "retroID": f.RetroID, "idx": f.Idx, "userID": f.UserID, "category": f.Category, "content": f.Content, "html": f.HTML, "created": f.Created, "updated": f.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*Feedback, util.ValueMap, error) {
ret := &Feedback{}
extra := util.ValueMap{}
Expand Down
5 changes: 5 additions & 0 deletions app/retro/retromap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/kyleu/rituals/app/util"
)

//nolint:lll
func (r *Retro) ToMap() util.ValueMap {
return util.ValueMap{"id": r.ID, "slug": r.Slug, "title": r.Title, "icon": r.Icon, "status": r.Status, "teamID": r.TeamID, "sprintID": r.SprintID, "categories": r.Categories, "created": r.Created, "updated": r.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*Retro, util.ValueMap, error) {
ret := &Retro{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/retro/rhistory/retrohistorymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package rhistory

import "github.com/kyleu/rituals/app/util"

func (r *RetroHistory) ToMap() util.ValueMap {
return util.ValueMap{"slug": r.Slug, "retroID": r.RetroID, "retroName": r.RetroName, "created": r.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*RetroHistory, util.ValueMap, error) {
ret := &RetroHistory{}
extra := util.ValueMap{}
Expand Down
5 changes: 5 additions & 0 deletions app/retro/rmember/retromembermap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/kyleu/rituals/app/util"
)

//nolint:lll
func (r *RetroMember) ToMap() util.ValueMap {
return util.ValueMap{"retroID": r.RetroID, "userID": r.UserID, "name": r.Name, "picture": r.Picture, "role": r.Role, "created": r.Created, "updated": r.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*RetroMember, util.ValueMap, error) {
ret := &RetroMember{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/retro/rpermission/retropermissionmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package rpermission

import "github.com/kyleu/rituals/app/util"

func (r *RetroPermission) ToMap() util.ValueMap {
return util.ValueMap{"retroID": r.RetroID, "key": r.Key, "value": r.Value, "access": r.Access, "created": r.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*RetroPermission, util.ValueMap, error) {
ret := &RetroPermission{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/sprint/shistory/sprinthistorymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package shistory

import "github.com/kyleu/rituals/app/util"

func (s *SprintHistory) ToMap() util.ValueMap {
return util.ValueMap{"slug": s.Slug, "sprintID": s.SprintID, "sprintName": s.SprintName, "created": s.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*SprintHistory, util.ValueMap, error) {
ret := &SprintHistory{}
extra := util.ValueMap{}
Expand Down
5 changes: 5 additions & 0 deletions app/sprint/smember/sprintmembermap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/kyleu/rituals/app/util"
)

//nolint:lll
func (s *SprintMember) ToMap() util.ValueMap {
return util.ValueMap{"sprintID": s.SprintID, "userID": s.UserID, "name": s.Name, "picture": s.Picture, "role": s.Role, "created": s.Created, "updated": s.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*SprintMember, util.ValueMap, error) {
ret := &SprintMember{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/sprint/spermission/sprintpermissionmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package spermission

import "github.com/kyleu/rituals/app/util"

func (s *SprintPermission) ToMap() util.ValueMap {
return util.ValueMap{"sprintID": s.SprintID, "key": s.Key, "value": s.Value, "access": s.Access, "created": s.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*SprintPermission, util.ValueMap, error) {
ret := &SprintPermission{}
extra := util.ValueMap{}
Expand Down
5 changes: 5 additions & 0 deletions app/sprint/sprintmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/kyleu/rituals/app/util"
)

//nolint:lll
func (s *Sprint) ToMap() util.ValueMap {
return util.ValueMap{"id": s.ID, "slug": s.Slug, "title": s.Title, "icon": s.Icon, "status": s.Status, "teamID": s.TeamID, "startDate": s.StartDate, "endDate": s.EndDate, "created": s.Created, "updated": s.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*Sprint, util.ValueMap, error) {
ret := &Sprint{}
extra := util.ValueMap{}
Expand Down
5 changes: 5 additions & 0 deletions app/standup/report/reportmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ package report

import "github.com/kyleu/rituals/app/util"

//nolint:lll
func (r *Report) ToMap() util.ValueMap {
return util.ValueMap{"id": r.ID, "standupID": r.StandupID, "day": r.Day, "userID": r.UserID, "content": r.Content, "html": r.HTML, "created": r.Created, "updated": r.Updated}
}

//nolint:gocognit
func FromMap(m util.ValueMap, setPK bool) (*Report, util.ValueMap, error) {
ret := &Report{}
Expand Down
5 changes: 5 additions & 0 deletions app/standup/standupmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/kyleu/rituals/app/util"
)

//nolint:lll
func (s *Standup) ToMap() util.ValueMap {
return util.ValueMap{"id": s.ID, "slug": s.Slug, "title": s.Title, "icon": s.Icon, "status": s.Status, "teamID": s.TeamID, "sprintID": s.SprintID, "created": s.Created, "updated": s.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*Standup, util.ValueMap, error) {
ret := &Standup{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/standup/uhistory/standuphistorymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package uhistory

import "github.com/kyleu/rituals/app/util"

func (s *StandupHistory) ToMap() util.ValueMap {
return util.ValueMap{"slug": s.Slug, "standupID": s.StandupID, "standupName": s.StandupName, "created": s.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*StandupHistory, util.ValueMap, error) {
ret := &StandupHistory{}
extra := util.ValueMap{}
Expand Down
5 changes: 5 additions & 0 deletions app/standup/umember/standupmembermap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/kyleu/rituals/app/util"
)

//nolint:lll
func (s *StandupMember) ToMap() util.ValueMap {
return util.ValueMap{"standupID": s.StandupID, "userID": s.UserID, "name": s.Name, "picture": s.Picture, "role": s.Role, "created": s.Created, "updated": s.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*StandupMember, util.ValueMap, error) {
ret := &StandupMember{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/standup/upermission/standuppermissionmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package upermission

import "github.com/kyleu/rituals/app/util"

func (s *StandupPermission) ToMap() util.ValueMap {
return util.ValueMap{"standupID": s.StandupID, "key": s.Key, "value": s.Value, "access": s.Access, "created": s.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*StandupPermission, util.ValueMap, error) {
ret := &StandupPermission{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/team/teammap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import (
"github.com/kyleu/rituals/app/util"
)

func (t *Team) ToMap() util.ValueMap {
return util.ValueMap{"id": t.ID, "slug": t.Slug, "title": t.Title, "icon": t.Icon, "status": t.Status, "created": t.Created, "updated": t.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*Team, util.ValueMap, error) {
ret := &Team{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/team/thistory/teamhistorymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package thistory

import "github.com/kyleu/rituals/app/util"

func (t *TeamHistory) ToMap() util.ValueMap {
return util.ValueMap{"slug": t.Slug, "teamID": t.TeamID, "teamName": t.TeamName, "created": t.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*TeamHistory, util.ValueMap, error) {
ret := &TeamHistory{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/team/tmember/teammembermap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import (
"github.com/kyleu/rituals/app/util"
)

func (t *TeamMember) ToMap() util.ValueMap {
return util.ValueMap{"teamID": t.TeamID, "userID": t.UserID, "name": t.Name, "picture": t.Picture, "role": t.Role, "created": t.Created, "updated": t.Updated}
}

func FromMap(m util.ValueMap, setPK bool) (*TeamMember, util.ValueMap, error) {
ret := &TeamMember{}
extra := util.ValueMap{}
Expand Down
4 changes: 4 additions & 0 deletions app/team/tpermission/teampermissionmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package tpermission

import "github.com/kyleu/rituals/app/util"

func (t *TeamPermission) ToMap() util.ValueMap {
return util.ValueMap{"teamID": t.TeamID, "key": t.Key, "value": t.Value, "access": t.Access, "created": t.Created}
}

func FromMap(m util.ValueMap, setPK bool) (*TeamPermission, util.ValueMap, error) {
ret := &TeamPermission{}
extra := util.ValueMap{}
Expand Down
Loading

0 comments on commit 02d1f46

Please sign in to comment.