Fix populating water report from ID, make ContactSimple

ContactSimple is the replacement for ContactReporter, which was the
simplified form of a contact from a report. I made the name more generic
and use it in the general report structures for consistency.
This commit is contained in:
Eli Ribble 2026-05-21 03:23:10 +00:00
parent 75d0283453
commit 5e103f46a0
No known key found for this signature in database
14 changed files with 103 additions and 108 deletions

View file

@ -1,7 +1,7 @@
package types
import (
//"github.com/rs/zerolog/log"
// "github.com/rs/zerolog/log"
)
type Contact struct {
@ -10,16 +10,16 @@ type Contact struct {
Name string `json:"name"`
Phones []Phone `json:"phones"`
}
type ContactReporter struct {
Email string `json:"email"`
Name string `json:"name"`
Phone PhoneReporter `json:"phone"`
type ContactSimple struct {
Email string `json:"email"`
Name string `json:"name"`
Phone PhoneSimple `json:"phone"`
}
type Phone struct {
E164 string `json:"e164"`
CanSMS bool `json:"can_sms"`
}
type PhoneReporter struct {
type PhoneSimple struct {
CanSMS bool `json:"can_sms"`
Number string `json:"number"`
}

View file

@ -2,6 +2,8 @@ package types
import (
"time"
"source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/publicreport/model"
)
type PublicReport struct {
@ -15,7 +17,7 @@ type PublicReport struct {
DistrictID *int32 `db:"organization_id" json:"-"`
District *string `db:"-" json:"district"`
PublicID string `db:"public_id" json:"public_id"`
Reporter ContactReporter `db:"reporter" json:"reporter"`
Reporter ContactSimple `db:"reporter" json:"reporter"`
Status string `db:"status" json:"status"`
Type string `db:"report_type" json:"type"`
URI string `db:"-" json:"uri"`
@ -56,19 +58,47 @@ type PublicReportNuisance struct {
}
type PublicReportWater struct {
PublicReport
AccessComments string `db:"access_comments" json:"access_comments"`
AccessGate bool `db:"access_gate" json:"access_gate"`
AccessFence bool `db:"access_fence" json:"access_fence"`
AccessLocked bool `db:"access_locked" json:"access_locked"`
AccessDog bool `db:"access_dog" json:"access_dog"`
AccessOther bool `db:"access_other" json:"access_other"`
Comments string `db:"comments" json:"comments"`
HasAdult bool `db:"has_adult" json:"has_adult"`
HasBackyardPermission bool `db:"has_backyard_permission" json:"has_backyard_permission"`
HasLarvae bool `db:"has_larvae" json:"has_larvae"`
HasPupae bool `db:"has_pupae" json:"has_pupae"`
IsReporterConfidential bool `db:"is_reporter_confidential" json:"is_reporter_confidential"`
IsReporterOwner bool `db:"is_reporter_owner" json:"is_reporter_owner"`
Owner Contact `db:"owner" json:"owner"`
ReportID int32 `db:"report_id" json:"-"`
AccessComments string `db:"access_comments" json:"access_comments"`
AccessGate bool `db:"access_gate" json:"access_gate"`
AccessFence bool `db:"access_fence" json:"access_fence"`
AccessLocked bool `db:"access_locked" json:"access_locked"`
AccessDog bool `db:"access_dog" json:"access_dog"`
AccessOther bool `db:"access_other" json:"access_other"`
Comments string `db:"comments" json:"comments"`
HasAdult bool `db:"has_adult" json:"has_adult"`
HasBackyardPermission bool `db:"has_backyard_permission" json:"has_backyard_permission"`
HasLarvae bool `db:"has_larvae" json:"has_larvae"`
HasPupae bool `db:"has_pupae" json:"has_pupae"`
IsReporterConfidential bool `db:"is_reporter_confidential" json:"is_reporter_confidential"`
IsReporterOwner bool `db:"is_reporter_owner" json:"is_reporter_owner"`
Owner ContactSimple `db:"owner" json:"owner"`
ReportID int32 `db:"report_id" json:"-"`
}
func PublicReportWaterFromModel(report PublicReport, water model.Water) PublicReportWater {
return PublicReportWater{
PublicReport: report,
AccessComments: water.AccessComments,
AccessGate: water.AccessGate,
AccessFence: water.AccessFence,
AccessLocked: water.AccessLocked,
AccessDog: water.AccessDog,
AccessOther: water.AccessOther,
Comments: water.Comments,
HasAdult: water.HasAdult,
HasBackyardPermission: water.HasBackyardPermission,
HasLarvae: water.HasLarvae,
HasPupae: water.HasPupae,
IsReporterConfidential: water.IsReporterConfidential,
IsReporterOwner: water.IsReporterOwner,
Owner: ContactSimple{
Email: water.OwnerEmail,
Name: water.OwnerName,
Phone: PhoneSimple{
CanSMS: false,
Number: water.OwnerPhone,
},
},
ReportID: water.ReportID,
}
}