From 287133e35d702304226c2d90fb6a2336c1b3244f Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 5 Feb 2026 02:24:37 +0000 Subject: [PATCH] Major updates to report status page for nuisance reports --- rmo/status.go | 94 ++++++++++++++++------------------ rmo/template/status-by-id.html | 63 +++++++++-------------- 2 files changed, 69 insertions(+), 88 deletions(-) diff --git a/rmo/status.go b/rmo/status.go index c5e875ac..8522ae96 100644 --- a/rmo/status.go +++ b/rmo/status.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/http" + "strconv" "strings" "time" @@ -25,11 +26,6 @@ import ( "github.com/aarondl/opt/omitnull" */) -type Contact struct { - Email string - Name string - Phone string -} type ContentStatus struct { District *ContentDistrict Error string @@ -38,26 +34,29 @@ type ContentStatus struct { URL ContentURL } type ContentStatusByID struct { + District *ContentDistrict MapboxToken string Report Report URL ContentURL } - +type DetailEntry struct { + Name string + Value string +} type Image struct { Location string URL string } type Report struct { - Address string - Comments string - Created time.Time - District string - ID string - Images []Image - Location string // GeoJSON - Reporter Contact - SiteOwner Contact - Type string + Address string + Comments string + Created time.Time + Details []DetailEntry + ID string + Images []Image + Location string // GeoJSON + Status string + Type string } var ( @@ -113,23 +112,45 @@ func contentFromNuisance(ctx context.Context, report_id string) (result ContentS result.Report.ID = report_id result.Report.Address = nuisance.Address result.Report.Created = nuisance.Created - result.Report.Reporter.Email = nuisance.ReporterEmail.GetOr("") - result.Report.Reporter.Name = nuisance.ReporterName.GetOr("") - result.Report.Reporter.Phone = nuisance.ReporterPhone.GetOr("") + result.Report.Status = nuisance.Status.String() + result.Report.Type = nuisance.Status.String() + result.Report.Details = []DetailEntry{ + DetailEntry{ + Name: "Active early morning?", + Value: "nah", + }, + DetailEntry{ + Name: "Duration", + Value: nuisance.Duration.String(), + }, + DetailEntry{ + Name: "Stagnant Water", + Value: strconv.FormatBool(nuisance.SourceStagnant), + }, + DetailEntry{ + Name: "Container", + Value: strconv.FormatBool(nuisance.SourceContainer), + }, + DetailEntry{ + Name: "Sprinklers & Gutters", + Value: "guess not", + }, + } type LocationGeoJSON struct { Location string } - row, err := bob.One(ctx, db.PGInstance.BobDB, psql.Select( - sm.From( + location, err := bob.One(ctx, db.PGInstance.BobDB, psql.Select( + sm.Columns( psql.F("ST_AsGeoJSON", "location"), - ).As("location"), + ), + sm.From("publicreport.quick"), sm.Where(psql.Quote("public_id").EQ(psql.Arg(report_id))), - ), scan.StructMapper[LocationGeoJSON]()) + ), scan.SingleColumnMapper[string]) if err != nil { return result, fmt.Errorf("Failed to query nuisance %s: %w", report_id, err) } - result.Report.Location = row.Location + result.Report.Location = location return result, err } @@ -153,10 +174,6 @@ func contentFromQuick(ctx context.Context, report_id string) (result ContentStat result.Report.Address = quick.Address result.Report.Comments = quick.Comments result.Report.Created = quick.Created - result.Report.District = "Unknown" - result.Report.Reporter.Email = quick.ReporterEmail - result.Report.Reporter.Name = "-" - result.Report.Reporter.Phone = quick.ReporterPhone result.Report.Type = "Quick" for _, image := range images { @@ -199,8 +216,6 @@ func getStatusByID(w http.ResponseWriter, r *http.Request) { content, err = contentFromNuisance(ctx, report_id) case "pool": content, err = contentFromPool(ctx, report_id) - case "quick": - content, err = contentFromQuick(ctx, report_id) } content.MapboxToken = config.MapboxToken content.URL = makeContentURL(nil) @@ -212,25 +227,6 @@ func getStatusByID(w http.ResponseWriter, r *http.Request) { } /* - func getQuick(w http.ResponseWriter, r *http.Request) { - html.RenderOrError( - w, - Quick, - ContentQuick{}, - ) - } - - func getQuickSubmitComplete(w http.ResponseWriter, r *http.Request) { - report := r.URL.Query().Get("report") - html.RenderOrError( - w, - QuickSubmitComplete, - ContentQuickSubmitComplete{ - ReportID: report, - }, - ) - } - func postQuick(w http.ResponseWriter, r *http.Request) { err := r.ParseMultipartForm(32 << 10) // 32 MB buffer if err != nil { diff --git a/rmo/template/status-by-id.html b/rmo/template/status-by-id.html index 3daf7b16..10610b78 100644 --- a/rmo/template/status-by-id.html +++ b/rmo/template/status-by-id.html @@ -64,12 +64,17 @@ document.addEventListener("DOMContentLoaded", onLoad); {{end}} {{define "content"}} +{{if (eq .District nil)}} + {{template "header-rmo" .}} +{{else}} + {{template "header-district" .District}} +{{end}}
Report {{.Report.ID|publicReportID}}
- Scheduled + Reported
@@ -83,50 +88,30 @@ document.addEventListener("DOMContentLoaded", onLoad);
District: - {{.Report.District}} + {{if (eq .District nil)}}Unknown{{else}}{{.District.Name}}{{end}}
-
-
- - -
-
-
-
-
Reporter Information
-
-
-

Name:{{.Report.Reporter.Name}}

-

Phone:{{.Report.Reporter.Phone}}

-

Email:{{.Report.Reporter.Email}}

+
+
+ Location: + {{.Report.Address}}
-
-
-
-
-
Reported Location
-
-
-

Site Contact Name:{{.Report.SiteOwner.Name}}

-

Site Contact Phone:{{.Report.SiteOwner.Phone}}

-

Site Contact Email:{{.Report.SiteOwner.Email}}

-

Address:{{.Report.Address}}

+
+
+ Images: + + {{ if gt (len .Report.Images) 0 }}{{len .Report.Images}}{{else}}None provided{{end}}
-
-
- - -
-
-
Report Detail
-
-
- {{ if not (eq .Report.Comments "") }} -

Comments:{{ .Report.Comments }}

- {{ end }} + {{range .Report.Details}} +
+
+ {{.Name}} + {{.Value}} +
+
+ {{end}}