From 5e638bdf1d6346fb22dd2c832b8c385f9e4ca5c1 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 24 Apr 2026 22:21:01 +0000 Subject: [PATCH] Remove hidden water inputs, add missing duration input --- db/dbinfo/publicreport.water.bob.go | 12 ++- .../00145_publicerport_water_duration.sql | 6 ++ db/models/publicreport.water.bob.go | 102 +++++++++++------- resource/publicreport_water.go | 42 ++++---- ts/rmo/content/Water.vue | 41 +------ 5 files changed, 107 insertions(+), 96 deletions(-) create mode 100644 db/migrations/00145_publicerport_water_duration.sql diff --git a/db/dbinfo/publicreport.water.bob.go b/db/dbinfo/publicreport.water.bob.go index 071115c7..07ecbaff 100644 --- a/db/dbinfo/publicreport.water.bob.go +++ b/db/dbinfo/publicreport.water.bob.go @@ -168,6 +168,15 @@ var PublicreportWaters = Table[ Generated: false, AutoIncr: false, }, + Duration: column{ + Name: "duration", + DBType: "publicreport.nuisancedurationtype", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, }, Indexes: publicreportWaterIndexes{ WaterPkey: index{ @@ -226,11 +235,12 @@ type publicreportWaterColumns struct { OwnerName column OwnerPhone column ReportID column + Duration column } func (c publicreportWaterColumns) AsSlice() []column { return []column{ - c.AccessComments, c.AccessGate, c.AccessFence, c.AccessLocked, c.AccessDog, c.AccessOther, c.Comments, c.IsReporterConfidential, c.IsReporterOwner, c.HasAdult, c.HasBackyardPermission, c.HasLarvae, c.HasPupae, c.OwnerEmail, c.OwnerName, c.OwnerPhone, c.ReportID, + c.AccessComments, c.AccessGate, c.AccessFence, c.AccessLocked, c.AccessDog, c.AccessOther, c.Comments, c.IsReporterConfidential, c.IsReporterOwner, c.HasAdult, c.HasBackyardPermission, c.HasLarvae, c.HasPupae, c.OwnerEmail, c.OwnerName, c.OwnerPhone, c.ReportID, c.Duration, } } diff --git a/db/migrations/00145_publicerport_water_duration.sql b/db/migrations/00145_publicerport_water_duration.sql new file mode 100644 index 00000000..75765b1f --- /dev/null +++ b/db/migrations/00145_publicerport_water_duration.sql @@ -0,0 +1,6 @@ +-- +goose Up +ALTER TABLE publicreport.water ADD COLUMN duration publicreport.NuisanceDurationType; +UPDATE publicreport.water SET duration = 'none'; +ALTER TABLE publicreport.water ALTER COLUMN duration SET NOT NULL; +-- +goose Down +ALTER TABLE publicreport.water DROP COLUMN duration; diff --git a/db/models/publicreport.water.bob.go b/db/models/publicreport.water.bob.go index b0b90e54..82eb3318 100644 --- a/db/models/publicreport.water.bob.go +++ b/db/models/publicreport.water.bob.go @@ -17,28 +17,30 @@ import ( "github.com/Gleipnir-Technology/bob/expr" "github.com/Gleipnir-Technology/bob/orm" "github.com/Gleipnir-Technology/bob/types/pgtypes" + enums "github.com/Gleipnir-Technology/nidus-sync/db/enums" "github.com/aarondl/opt/omit" ) // PublicreportWater is an object representing the database table. type PublicreportWater struct { - AccessComments string `db:"access_comments" ` - AccessGate bool `db:"access_gate" ` - AccessFence bool `db:"access_fence" ` - AccessLocked bool `db:"access_locked" ` - AccessDog bool `db:"access_dog" ` - AccessOther bool `db:"access_other" ` - Comments string `db:"comments" ` - IsReporterConfidential bool `db:"is_reporter_confidential" ` - IsReporterOwner bool `db:"is_reporter_owner" ` - HasAdult bool `db:"has_adult" ` - HasBackyardPermission bool `db:"has_backyard_permission" ` - HasLarvae bool `db:"has_larvae" ` - HasPupae bool `db:"has_pupae" ` - OwnerEmail string `db:"owner_email" ` - OwnerName string `db:"owner_name" ` - OwnerPhone string `db:"owner_phone" ` - ReportID int32 `db:"report_id,pk" ` + AccessComments string `db:"access_comments" ` + AccessGate bool `db:"access_gate" ` + AccessFence bool `db:"access_fence" ` + AccessLocked bool `db:"access_locked" ` + AccessDog bool `db:"access_dog" ` + AccessOther bool `db:"access_other" ` + Comments string `db:"comments" ` + IsReporterConfidential bool `db:"is_reporter_confidential" ` + IsReporterOwner bool `db:"is_reporter_owner" ` + HasAdult bool `db:"has_adult" ` + HasBackyardPermission bool `db:"has_backyard_permission" ` + HasLarvae bool `db:"has_larvae" ` + HasPupae bool `db:"has_pupae" ` + OwnerEmail string `db:"owner_email" ` + OwnerName string `db:"owner_name" ` + OwnerPhone string `db:"owner_phone" ` + ReportID int32 `db:"report_id,pk" ` + Duration enums.PublicreportNuisancedurationtype `db:"duration" ` R publicreportWaterR `db:"-" ` } @@ -61,7 +63,7 @@ type publicreportWaterR struct { func buildPublicreportWaterColumns(alias string) publicreportWaterColumns { return publicreportWaterColumns{ ColumnsExpr: expr.NewColumnsExpr( - "access_comments", "access_gate", "access_fence", "access_locked", "access_dog", "access_other", "comments", "is_reporter_confidential", "is_reporter_owner", "has_adult", "has_backyard_permission", "has_larvae", "has_pupae", "owner_email", "owner_name", "owner_phone", "report_id", + "access_comments", "access_gate", "access_fence", "access_locked", "access_dog", "access_other", "comments", "is_reporter_confidential", "is_reporter_owner", "has_adult", "has_backyard_permission", "has_larvae", "has_pupae", "owner_email", "owner_name", "owner_phone", "report_id", "duration", ).WithParent("publicreport.water"), tableAlias: alias, AccessComments: psql.Quote(alias, "access_comments"), @@ -81,6 +83,7 @@ func buildPublicreportWaterColumns(alias string) publicreportWaterColumns { OwnerName: psql.Quote(alias, "owner_name"), OwnerPhone: psql.Quote(alias, "owner_phone"), ReportID: psql.Quote(alias, "report_id"), + Duration: psql.Quote(alias, "duration"), } } @@ -104,6 +107,7 @@ type publicreportWaterColumns struct { OwnerName psql.Expression OwnerPhone psql.Expression ReportID psql.Expression + Duration psql.Expression } func (c publicreportWaterColumns) Alias() string { @@ -118,27 +122,28 @@ func (publicreportWaterColumns) AliasedAs(alias string) publicreportWaterColumns // All values are optional, and do not have to be set // Generated columns are not included type PublicreportWaterSetter struct { - AccessComments omit.Val[string] `db:"access_comments" ` - AccessGate omit.Val[bool] `db:"access_gate" ` - AccessFence omit.Val[bool] `db:"access_fence" ` - AccessLocked omit.Val[bool] `db:"access_locked" ` - AccessDog omit.Val[bool] `db:"access_dog" ` - AccessOther omit.Val[bool] `db:"access_other" ` - Comments omit.Val[string] `db:"comments" ` - IsReporterConfidential omit.Val[bool] `db:"is_reporter_confidential" ` - IsReporterOwner omit.Val[bool] `db:"is_reporter_owner" ` - HasAdult omit.Val[bool] `db:"has_adult" ` - HasBackyardPermission omit.Val[bool] `db:"has_backyard_permission" ` - HasLarvae omit.Val[bool] `db:"has_larvae" ` - HasPupae omit.Val[bool] `db:"has_pupae" ` - OwnerEmail omit.Val[string] `db:"owner_email" ` - OwnerName omit.Val[string] `db:"owner_name" ` - OwnerPhone omit.Val[string] `db:"owner_phone" ` - ReportID omit.Val[int32] `db:"report_id,pk" ` + AccessComments omit.Val[string] `db:"access_comments" ` + AccessGate omit.Val[bool] `db:"access_gate" ` + AccessFence omit.Val[bool] `db:"access_fence" ` + AccessLocked omit.Val[bool] `db:"access_locked" ` + AccessDog omit.Val[bool] `db:"access_dog" ` + AccessOther omit.Val[bool] `db:"access_other" ` + Comments omit.Val[string] `db:"comments" ` + IsReporterConfidential omit.Val[bool] `db:"is_reporter_confidential" ` + IsReporterOwner omit.Val[bool] `db:"is_reporter_owner" ` + HasAdult omit.Val[bool] `db:"has_adult" ` + HasBackyardPermission omit.Val[bool] `db:"has_backyard_permission" ` + HasLarvae omit.Val[bool] `db:"has_larvae" ` + HasPupae omit.Val[bool] `db:"has_pupae" ` + OwnerEmail omit.Val[string] `db:"owner_email" ` + OwnerName omit.Val[string] `db:"owner_name" ` + OwnerPhone omit.Val[string] `db:"owner_phone" ` + ReportID omit.Val[int32] `db:"report_id,pk" ` + Duration omit.Val[enums.PublicreportNuisancedurationtype] `db:"duration" ` } func (s PublicreportWaterSetter) SetColumns() []string { - vals := make([]string, 0, 17) + vals := make([]string, 0, 18) if s.AccessComments.IsValue() { vals = append(vals, "access_comments") } @@ -190,6 +195,9 @@ func (s PublicreportWaterSetter) SetColumns() []string { if s.ReportID.IsValue() { vals = append(vals, "report_id") } + if s.Duration.IsValue() { + vals = append(vals, "duration") + } return vals } @@ -245,6 +253,9 @@ func (s PublicreportWaterSetter) Overwrite(t *PublicreportWater) { if s.ReportID.IsValue() { t.ReportID = s.ReportID.MustGet() } + if s.Duration.IsValue() { + t.Duration = s.Duration.MustGet() + } } func (s *PublicreportWaterSetter) Apply(q *dialect.InsertQuery) { @@ -253,7 +264,7 @@ func (s *PublicreportWaterSetter) Apply(q *dialect.InsertQuery) { }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - vals := make([]bob.Expression, 17) + vals := make([]bob.Expression, 18) if s.AccessComments.IsValue() { vals[0] = psql.Arg(s.AccessComments.MustGet()) } else { @@ -356,6 +367,12 @@ func (s *PublicreportWaterSetter) Apply(q *dialect.InsertQuery) { vals[16] = psql.Raw("DEFAULT") } + if s.Duration.IsValue() { + vals[17] = psql.Arg(s.Duration.MustGet()) + } else { + vals[17] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -365,7 +382,7 @@ func (s PublicreportWaterSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { } func (s PublicreportWaterSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 17) + exprs := make([]bob.Expression, 0, 18) if s.AccessComments.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -486,6 +503,13 @@ func (s PublicreportWaterSetter) Expressions(prefix ...string) []bob.Expression }}) } + if s.Duration.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "duration")...), + psql.Arg(s.Duration), + }}) + } + return exprs } @@ -802,6 +826,7 @@ type publicreportWaterWhere[Q psql.Filterable] struct { OwnerName psql.WhereMod[Q, string] OwnerPhone psql.WhereMod[Q, string] ReportID psql.WhereMod[Q, int32] + Duration psql.WhereMod[Q, enums.PublicreportNuisancedurationtype] } func (publicreportWaterWhere[Q]) AliasedAs(alias string) publicreportWaterWhere[Q] { @@ -827,6 +852,7 @@ func buildPublicreportWaterWhere[Q psql.Filterable](cols publicreportWaterColumn OwnerName: psql.Where[Q, string](cols.OwnerName), OwnerPhone: psql.Where[Q, string](cols.OwnerPhone), ReportID: psql.Where[Q, int32](cols.ReportID), + Duration: psql.Where[Q, enums.PublicreportNuisancedurationtype](cols.Duration), } } diff --git a/resource/publicreport_water.go b/resource/publicreport_water.go index 400aa4a7..43fd1a94 100644 --- a/resource/publicreport_water.go +++ b/resource/publicreport_water.go @@ -33,26 +33,27 @@ type water struct { URI string `json:"uri"` } type waterForm struct { - AccessComments string `schema:"access-comments"` - AccessDog bool `schema:"access-dog"` - AccessFence bool `schema:"access-fence"` - AccessGate bool `schema:"access-gate"` - AccessLocked bool `schema:"access-locked"` - AccessOther bool `schema:"access-other"` - Address types.Address `schema:"address"` - AddressGID string `schema:"address-gid"` - ClientID uuid.UUID `schema:"client_id" json:"client_id"` - Comments string `schema:"comments"` - HasAdult bool `schema:"has-adult"` - HasBackyardPermission bool `schema:"backyard-permission"` - HasLarvae bool `schema:"has-larvae"` - HasPupae bool `schema:"has-pupae"` - IsReporterConfidential bool `schema:"reporter-confidential"` - IsReporter_owner bool `schema:"property-ownership"` - Location types.Location `schema:"location"` - OwnerEmail string `schema:"owner-email"` - OwnerName string `schema:"owner-name"` - OwnerPhone string `schema:"owner-phone"` + AccessComments string `schema:"access-comments"` + AccessDog bool `schema:"access-dog"` + AccessFence bool `schema:"access-fence"` + AccessGate bool `schema:"access-gate"` + AccessLocked bool `schema:"access-locked"` + AccessOther bool `schema:"access-other"` + Address types.Address `schema:"address"` + AddressGID string `schema:"address-gid"` + ClientID uuid.UUID `schema:"client_id" json:"client_id"` + Comments string `schema:"comments"` + Duration omit.Val[enums.PublicreportNuisancedurationtype] `schema:"duration"` + HasAdult bool `schema:"has-adult"` + HasBackyardPermission bool `schema:"backyard-permission"` + HasLarvae bool `schema:"has-larvae"` + HasPupae bool `schema:"has-pupae"` + IsReporterConfidential bool `schema:"reporter-confidential"` + IsReporter_owner bool `schema:"property-ownership"` + Location types.Location `schema:"location"` + OwnerEmail string `schema:"owner-email"` + OwnerName string `schema:"owner-name"` + OwnerPhone string `schema:"owner-phone"` } func (res *waterR) ByID(ctx context.Context, r *http.Request, query QueryParams) (*types.PublicReportWater, *nhttp.ErrorWithStatus) { @@ -115,6 +116,7 @@ func (res *waterR) Create(ctx context.Context, r *http.Request, w waterForm) (*w AccessLocked: omit.From(w.AccessLocked), AccessOther: omit.From(w.AccessOther), Comments: omit.From(w.Comments), + Duration: w.Duration, HasAdult: omit.From(w.HasAdult), HasBackyardPermission: omit.From(w.HasBackyardPermission), HasLarvae: omit.From(w.HasLarvae), diff --git a/ts/rmo/content/Water.vue b/ts/rmo/content/Water.vue index 7dc6b101..b1d17620 100644 --- a/ts/rmo/content/Water.vue +++ b/ts/rmo/content/Water.vue @@ -207,36 +207,6 @@ select.tall { -
- - - - - - - - - - - -
-

You can also click on the map to mark the location precisely

@@ -266,17 +236,14 @@ select.tall { - - + + - +