diff --git a/db/dberrors/publicreport.nuisance.bob.go b/db/dberrors/publicreport.nuisance.bob.go new file mode 100644 index 00000000..fe815789 --- /dev/null +++ b/db/dberrors/publicreport.nuisance.bob.go @@ -0,0 +1,26 @@ +// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package dberrors + +var PublicreportNuisanceErrors = &publicreportNuisanceErrors{ + ErrUniqueNuisancePkey: &UniqueConstraintError{ + schema: "publicreport", + table: "nuisance", + columns: []string{"id"}, + s: "nuisance_pkey", + }, + + ErrUniqueNuisancePublicIdKey: &UniqueConstraintError{ + schema: "publicreport", + table: "nuisance", + columns: []string{"public_id"}, + s: "nuisance_public_id_key", + }, +} + +type publicreportNuisanceErrors struct { + ErrUniqueNuisancePkey *UniqueConstraintError + + ErrUniqueNuisancePublicIdKey *UniqueConstraintError +} diff --git a/db/dbinfo/publicreport.nuisance.bob.go b/db/dbinfo/publicreport.nuisance.bob.go new file mode 100644 index 00000000..75737643 --- /dev/null +++ b/db/dbinfo/publicreport.nuisance.bob.go @@ -0,0 +1,352 @@ +// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package dbinfo + +import "github.com/aarondl/opt/null" + +var PublicreportNuisances = Table[ + publicreportNuisanceColumns, + publicreportNuisanceIndexes, + publicreportNuisanceForeignKeys, + publicreportNuisanceUniques, + publicreportNuisanceChecks, +]{ + Schema: "publicreport", + Name: "nuisance", + Columns: publicreportNuisanceColumns{ + ID: column{ + Name: "id", + DBType: "integer", + Default: "nextval('publicreport.nuisance_id_seq'::regclass)", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + AdditionalInfo: column{ + Name: "additional_info", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Created: column{ + Name: "created", + DBType: "timestamp without time zone", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Duration: column{ + Name: "duration", + DBType: "publicreport.nuisancedurationtype", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Email: column{ + Name: "email", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + InspectionType: column{ + Name: "inspection_type", + DBType: "publicreport.nuisanceinspectiontype", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Location: column{ + Name: "location", + DBType: "publicreport.nuisancelocationtype", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + PreferredDateRange: column{ + Name: "preferred_date_range", + DBType: "publicreport.nuisancepreferreddaterangetype", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + PreferredTime: column{ + Name: "preferred_time", + DBType: "publicreport.nuisancepreferredtimetype", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + RequestCall: column{ + Name: "request_call", + DBType: "boolean", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Severity: column{ + Name: "severity", + DBType: "smallint", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + SourceContainer: column{ + Name: "source_container", + DBType: "boolean", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + SourceDescription: column{ + Name: "source_description", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + SourceRoof: column{ + Name: "source_roof", + DBType: "boolean", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + SourceStagnant: column{ + Name: "source_stagnant", + DBType: "boolean", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + TimeOfDayDay: column{ + Name: "time_of_day_day", + DBType: "boolean", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + TimeOfDayEarly: column{ + Name: "time_of_day_early", + DBType: "boolean", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + TimeOfDayEvening: column{ + Name: "time_of_day_evening", + DBType: "boolean", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + TimeOfDayNight: column{ + Name: "time_of_day_night", + DBType: "boolean", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + PublicID: column{ + Name: "public_id", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + ReporterAddress: column{ + Name: "reporter_address", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + ReporterEmail: column{ + Name: "reporter_email", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + ReporterName: column{ + Name: "reporter_name", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + ReporterPhone: column{ + Name: "reporter_phone", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + }, + Indexes: publicreportNuisanceIndexes{ + NuisancePkey: index{ + Type: "btree", + Name: "nuisance_pkey", + Columns: []indexColumn{ + { + Name: "id", + Desc: null.FromCond(false, true), + IsExpression: false, + }, + }, + Unique: true, + Comment: "", + NullsFirst: []bool{false}, + NullsDistinct: false, + Where: "", + Include: []string{}, + }, + NuisancePublicIDKey: index{ + Type: "btree", + Name: "nuisance_public_id_key", + Columns: []indexColumn{ + { + Name: "public_id", + Desc: null.FromCond(false, true), + IsExpression: false, + }, + }, + Unique: true, + Comment: "", + NullsFirst: []bool{false}, + NullsDistinct: false, + Where: "", + Include: []string{}, + }, + }, + PrimaryKey: &constraint{ + Name: "nuisance_pkey", + Columns: []string{"id"}, + Comment: "", + }, + + Uniques: publicreportNuisanceUniques{ + NuisancePublicIDKey: constraint{ + Name: "nuisance_public_id_key", + Columns: []string{"public_id"}, + Comment: "", + }, + }, + + Comment: "", +} + +type publicreportNuisanceColumns struct { + ID column + AdditionalInfo column + Created column + Duration column + Email column + InspectionType column + Location column + PreferredDateRange column + PreferredTime column + RequestCall column + Severity column + SourceContainer column + SourceDescription column + SourceRoof column + SourceStagnant column + TimeOfDayDay column + TimeOfDayEarly column + TimeOfDayEvening column + TimeOfDayNight column + PublicID column + ReporterAddress column + ReporterEmail column + ReporterName column + ReporterPhone column +} + +func (c publicreportNuisanceColumns) AsSlice() []column { + return []column{ + c.ID, c.AdditionalInfo, c.Created, c.Duration, c.Email, c.InspectionType, c.Location, c.PreferredDateRange, c.PreferredTime, c.RequestCall, c.Severity, c.SourceContainer, c.SourceDescription, c.SourceRoof, c.SourceStagnant, c.TimeOfDayDay, c.TimeOfDayEarly, c.TimeOfDayEvening, c.TimeOfDayNight, c.PublicID, c.ReporterAddress, c.ReporterEmail, c.ReporterName, c.ReporterPhone, + } +} + +type publicreportNuisanceIndexes struct { + NuisancePkey index + NuisancePublicIDKey index +} + +func (i publicreportNuisanceIndexes) AsSlice() []index { + return []index{ + i.NuisancePkey, i.NuisancePublicIDKey, + } +} + +type publicreportNuisanceForeignKeys struct{} + +func (f publicreportNuisanceForeignKeys) AsSlice() []foreignKey { + return []foreignKey{} +} + +type publicreportNuisanceUniques struct { + NuisancePublicIDKey constraint +} + +func (u publicreportNuisanceUniques) AsSlice() []constraint { + return []constraint{ + u.NuisancePublicIDKey, + } +} + +type publicreportNuisanceChecks struct{} + +func (c publicreportNuisanceChecks) AsSlice() []check { + return []check{} +} diff --git a/db/enums/enums.bob.go b/db/enums/enums.bob.go index b10448e7..d4867742 100644 --- a/db/enums/enums.bob.go +++ b/db/enums/enums.bob.go @@ -477,3 +477,416 @@ func (e *Notificationtype) Scan(value any) error { return nil } + +// Enum values for PublicreportNuisancedurationtype +const ( + PublicreportNuisancedurationtypeNone PublicreportNuisancedurationtype = "none" + PublicreportNuisancedurationtypeJustNoticed PublicreportNuisancedurationtype = "just-noticed" + PublicreportNuisancedurationtypeFewDays PublicreportNuisancedurationtype = "few-days" + PublicreportNuisancedurationtype12Weeks PublicreportNuisancedurationtype = "1-2-weeks" + PublicreportNuisancedurationtype24Weeks PublicreportNuisancedurationtype = "2-4-weeks" + PublicreportNuisancedurationtype13Months PublicreportNuisancedurationtype = "1-3-months" + PublicreportNuisancedurationtypeSeasonal PublicreportNuisancedurationtype = "seasonal" +) + +func AllPublicreportNuisancedurationtype() []PublicreportNuisancedurationtype { + return []PublicreportNuisancedurationtype{ + PublicreportNuisancedurationtypeNone, + PublicreportNuisancedurationtypeJustNoticed, + PublicreportNuisancedurationtypeFewDays, + PublicreportNuisancedurationtype12Weeks, + PublicreportNuisancedurationtype24Weeks, + PublicreportNuisancedurationtype13Months, + PublicreportNuisancedurationtypeSeasonal, + } +} + +type PublicreportNuisancedurationtype string + +func (e PublicreportNuisancedurationtype) String() string { + return string(e) +} + +func (e PublicreportNuisancedurationtype) Valid() bool { + switch e { + case PublicreportNuisancedurationtypeNone, + PublicreportNuisancedurationtypeJustNoticed, + PublicreportNuisancedurationtypeFewDays, + PublicreportNuisancedurationtype12Weeks, + PublicreportNuisancedurationtype24Weeks, + PublicreportNuisancedurationtype13Months, + PublicreportNuisancedurationtypeSeasonal: + return true + default: + return false + } +} + +// useful when testing in other packages +func (e PublicreportNuisancedurationtype) All() []PublicreportNuisancedurationtype { + return AllPublicreportNuisancedurationtype() +} + +func (e PublicreportNuisancedurationtype) MarshalText() ([]byte, error) { + return []byte(e), nil +} + +func (e *PublicreportNuisancedurationtype) UnmarshalText(text []byte) error { + return e.Scan(text) +} + +func (e PublicreportNuisancedurationtype) MarshalBinary() ([]byte, error) { + return []byte(e), nil +} + +func (e *PublicreportNuisancedurationtype) UnmarshalBinary(data []byte) error { + return e.Scan(data) +} + +func (e PublicreportNuisancedurationtype) Value() (driver.Value, error) { + return string(e), nil +} + +func (e *PublicreportNuisancedurationtype) Scan(value any) error { + switch x := value.(type) { + case string: + *e = PublicreportNuisancedurationtype(x) + case []byte: + *e = PublicreportNuisancedurationtype(x) + case nil: + return fmt.Errorf("cannot nil into PublicreportNuisancedurationtype") + default: + return fmt.Errorf("cannot scan type %T: %v", value, value) + } + + if !e.Valid() { + return fmt.Errorf("invalid PublicreportNuisancedurationtype value: %s", *e) + } + + return nil +} + +// Enum values for PublicreportNuisanceinspectiontype +const ( + PublicreportNuisanceinspectiontypeNeighborhood PublicreportNuisanceinspectiontype = "neighborhood" + PublicreportNuisanceinspectiontypeProperty PublicreportNuisanceinspectiontype = "property" +) + +func AllPublicreportNuisanceinspectiontype() []PublicreportNuisanceinspectiontype { + return []PublicreportNuisanceinspectiontype{ + PublicreportNuisanceinspectiontypeNeighborhood, + PublicreportNuisanceinspectiontypeProperty, + } +} + +type PublicreportNuisanceinspectiontype string + +func (e PublicreportNuisanceinspectiontype) String() string { + return string(e) +} + +func (e PublicreportNuisanceinspectiontype) Valid() bool { + switch e { + case PublicreportNuisanceinspectiontypeNeighborhood, + PublicreportNuisanceinspectiontypeProperty: + return true + default: + return false + } +} + +// useful when testing in other packages +func (e PublicreportNuisanceinspectiontype) All() []PublicreportNuisanceinspectiontype { + return AllPublicreportNuisanceinspectiontype() +} + +func (e PublicreportNuisanceinspectiontype) MarshalText() ([]byte, error) { + return []byte(e), nil +} + +func (e *PublicreportNuisanceinspectiontype) UnmarshalText(text []byte) error { + return e.Scan(text) +} + +func (e PublicreportNuisanceinspectiontype) MarshalBinary() ([]byte, error) { + return []byte(e), nil +} + +func (e *PublicreportNuisanceinspectiontype) UnmarshalBinary(data []byte) error { + return e.Scan(data) +} + +func (e PublicreportNuisanceinspectiontype) Value() (driver.Value, error) { + return string(e), nil +} + +func (e *PublicreportNuisanceinspectiontype) Scan(value any) error { + switch x := value.(type) { + case string: + *e = PublicreportNuisanceinspectiontype(x) + case []byte: + *e = PublicreportNuisanceinspectiontype(x) + case nil: + return fmt.Errorf("cannot nil into PublicreportNuisanceinspectiontype") + default: + return fmt.Errorf("cannot scan type %T: %v", value, value) + } + + if !e.Valid() { + return fmt.Errorf("invalid PublicreportNuisanceinspectiontype value: %s", *e) + } + + return nil +} + +// Enum values for PublicreportNuisancelocationtype +const ( + PublicreportNuisancelocationtypeNone PublicreportNuisancelocationtype = "none" + PublicreportNuisancelocationtypeFrontYard PublicreportNuisancelocationtype = "front-yard" + PublicreportNuisancelocationtypeBackyard PublicreportNuisancelocationtype = "backyard" + PublicreportNuisancelocationtypePatio PublicreportNuisancelocationtype = "patio" + PublicreportNuisancelocationtypeGarden PublicreportNuisancelocationtype = "garden" + PublicreportNuisancelocationtypePoolArea PublicreportNuisancelocationtype = "pool-area" + PublicreportNuisancelocationtypeThroughout PublicreportNuisancelocationtype = "throughout" + PublicreportNuisancelocationtypeIndoors PublicreportNuisancelocationtype = "indoors" + PublicreportNuisancelocationtypeOther PublicreportNuisancelocationtype = "other" +) + +func AllPublicreportNuisancelocationtype() []PublicreportNuisancelocationtype { + return []PublicreportNuisancelocationtype{ + PublicreportNuisancelocationtypeNone, + PublicreportNuisancelocationtypeFrontYard, + PublicreportNuisancelocationtypeBackyard, + PublicreportNuisancelocationtypePatio, + PublicreportNuisancelocationtypeGarden, + PublicreportNuisancelocationtypePoolArea, + PublicreportNuisancelocationtypeThroughout, + PublicreportNuisancelocationtypeIndoors, + PublicreportNuisancelocationtypeOther, + } +} + +type PublicreportNuisancelocationtype string + +func (e PublicreportNuisancelocationtype) String() string { + return string(e) +} + +func (e PublicreportNuisancelocationtype) Valid() bool { + switch e { + case PublicreportNuisancelocationtypeNone, + PublicreportNuisancelocationtypeFrontYard, + PublicreportNuisancelocationtypeBackyard, + PublicreportNuisancelocationtypePatio, + PublicreportNuisancelocationtypeGarden, + PublicreportNuisancelocationtypePoolArea, + PublicreportNuisancelocationtypeThroughout, + PublicreportNuisancelocationtypeIndoors, + PublicreportNuisancelocationtypeOther: + return true + default: + return false + } +} + +// useful when testing in other packages +func (e PublicreportNuisancelocationtype) All() []PublicreportNuisancelocationtype { + return AllPublicreportNuisancelocationtype() +} + +func (e PublicreportNuisancelocationtype) MarshalText() ([]byte, error) { + return []byte(e), nil +} + +func (e *PublicreportNuisancelocationtype) UnmarshalText(text []byte) error { + return e.Scan(text) +} + +func (e PublicreportNuisancelocationtype) MarshalBinary() ([]byte, error) { + return []byte(e), nil +} + +func (e *PublicreportNuisancelocationtype) UnmarshalBinary(data []byte) error { + return e.Scan(data) +} + +func (e PublicreportNuisancelocationtype) Value() (driver.Value, error) { + return string(e), nil +} + +func (e *PublicreportNuisancelocationtype) Scan(value any) error { + switch x := value.(type) { + case string: + *e = PublicreportNuisancelocationtype(x) + case []byte: + *e = PublicreportNuisancelocationtype(x) + case nil: + return fmt.Errorf("cannot nil into PublicreportNuisancelocationtype") + default: + return fmt.Errorf("cannot scan type %T: %v", value, value) + } + + if !e.Valid() { + return fmt.Errorf("invalid PublicreportNuisancelocationtype value: %s", *e) + } + + return nil +} + +// Enum values for PublicreportNuisancepreferreddaterangetype +const ( + PublicreportNuisancepreferreddaterangetypeNone PublicreportNuisancepreferreddaterangetype = "none" + PublicreportNuisancepreferreddaterangetypeAnyTime PublicreportNuisancepreferreddaterangetype = "any-time" + PublicreportNuisancepreferreddaterangetypeInTwoWeeks PublicreportNuisancepreferreddaterangetype = "in-two-weeks" + PublicreportNuisancepreferreddaterangetypeNextWeek PublicreportNuisancepreferreddaterangetype = "next-week" +) + +func AllPublicreportNuisancepreferreddaterangetype() []PublicreportNuisancepreferreddaterangetype { + return []PublicreportNuisancepreferreddaterangetype{ + PublicreportNuisancepreferreddaterangetypeNone, + PublicreportNuisancepreferreddaterangetypeAnyTime, + PublicreportNuisancepreferreddaterangetypeInTwoWeeks, + PublicreportNuisancepreferreddaterangetypeNextWeek, + } +} + +type PublicreportNuisancepreferreddaterangetype string + +func (e PublicreportNuisancepreferreddaterangetype) String() string { + return string(e) +} + +func (e PublicreportNuisancepreferreddaterangetype) Valid() bool { + switch e { + case PublicreportNuisancepreferreddaterangetypeNone, + PublicreportNuisancepreferreddaterangetypeAnyTime, + PublicreportNuisancepreferreddaterangetypeInTwoWeeks, + PublicreportNuisancepreferreddaterangetypeNextWeek: + return true + default: + return false + } +} + +// useful when testing in other packages +func (e PublicreportNuisancepreferreddaterangetype) All() []PublicreportNuisancepreferreddaterangetype { + return AllPublicreportNuisancepreferreddaterangetype() +} + +func (e PublicreportNuisancepreferreddaterangetype) MarshalText() ([]byte, error) { + return []byte(e), nil +} + +func (e *PublicreportNuisancepreferreddaterangetype) UnmarshalText(text []byte) error { + return e.Scan(text) +} + +func (e PublicreportNuisancepreferreddaterangetype) MarshalBinary() ([]byte, error) { + return []byte(e), nil +} + +func (e *PublicreportNuisancepreferreddaterangetype) UnmarshalBinary(data []byte) error { + return e.Scan(data) +} + +func (e PublicreportNuisancepreferreddaterangetype) Value() (driver.Value, error) { + return string(e), nil +} + +func (e *PublicreportNuisancepreferreddaterangetype) Scan(value any) error { + switch x := value.(type) { + case string: + *e = PublicreportNuisancepreferreddaterangetype(x) + case []byte: + *e = PublicreportNuisancepreferreddaterangetype(x) + case nil: + return fmt.Errorf("cannot nil into PublicreportNuisancepreferreddaterangetype") + default: + return fmt.Errorf("cannot scan type %T: %v", value, value) + } + + if !e.Valid() { + return fmt.Errorf("invalid PublicreportNuisancepreferreddaterangetype value: %s", *e) + } + + return nil +} + +// Enum values for PublicreportNuisancepreferredtimetype +const ( + PublicreportNuisancepreferredtimetypeNone PublicreportNuisancepreferredtimetype = "none" + PublicreportNuisancepreferredtimetypeAfternoon PublicreportNuisancepreferredtimetype = "afternoon" + PublicreportNuisancepreferredtimetypeAnyTime PublicreportNuisancepreferredtimetype = "any-time" + PublicreportNuisancepreferredtimetypeMorning PublicreportNuisancepreferredtimetype = "morning" +) + +func AllPublicreportNuisancepreferredtimetype() []PublicreportNuisancepreferredtimetype { + return []PublicreportNuisancepreferredtimetype{ + PublicreportNuisancepreferredtimetypeNone, + PublicreportNuisancepreferredtimetypeAfternoon, + PublicreportNuisancepreferredtimetypeAnyTime, + PublicreportNuisancepreferredtimetypeMorning, + } +} + +type PublicreportNuisancepreferredtimetype string + +func (e PublicreportNuisancepreferredtimetype) String() string { + return string(e) +} + +func (e PublicreportNuisancepreferredtimetype) Valid() bool { + switch e { + case PublicreportNuisancepreferredtimetypeNone, + PublicreportNuisancepreferredtimetypeAfternoon, + PublicreportNuisancepreferredtimetypeAnyTime, + PublicreportNuisancepreferredtimetypeMorning: + return true + default: + return false + } +} + +// useful when testing in other packages +func (e PublicreportNuisancepreferredtimetype) All() []PublicreportNuisancepreferredtimetype { + return AllPublicreportNuisancepreferredtimetype() +} + +func (e PublicreportNuisancepreferredtimetype) MarshalText() ([]byte, error) { + return []byte(e), nil +} + +func (e *PublicreportNuisancepreferredtimetype) UnmarshalText(text []byte) error { + return e.Scan(text) +} + +func (e PublicreportNuisancepreferredtimetype) MarshalBinary() ([]byte, error) { + return []byte(e), nil +} + +func (e *PublicreportNuisancepreferredtimetype) UnmarshalBinary(data []byte) error { + return e.Scan(data) +} + +func (e PublicreportNuisancepreferredtimetype) Value() (driver.Value, error) { + return string(e), nil +} + +func (e *PublicreportNuisancepreferredtimetype) Scan(value any) error { + switch x := value.(type) { + case string: + *e = PublicreportNuisancepreferredtimetype(x) + case []byte: + *e = PublicreportNuisancepreferredtimetype(x) + case nil: + return fmt.Errorf("cannot nil into PublicreportNuisancepreferredtimetype") + default: + return fmt.Errorf("cannot scan type %T: %v", value, value) + } + + if !e.Valid() { + return fmt.Errorf("invalid PublicreportNuisancepreferredtimetype value: %s", *e) + } + + return nil +} diff --git a/db/factory/bobfactory_context.bob.go b/db/factory/bobfactory_context.bob.go index 3cb78550..f5fa3f8e 100644 --- a/db/factory/bobfactory_context.bob.go +++ b/db/factory/bobfactory_context.bob.go @@ -208,6 +208,9 @@ var ( organizationRelNoteImagesCtx = newContextual[bool]("note_image.organization.note_image.note_image_organization_id_fkey") organizationRelUserCtx = newContextual[bool]("organization.user_.user_.user__organization_id_fkey") + // Relationship Contexts for publicreport.nuisance + publicreportNuisanceWithParentsCascadingCtx = newContextual[bool]("publicreportNuisanceWithParentsCascading") + // Relationship Contexts for publicreport.quick publicreportQuickWithParentsCascadingCtx = newContextual[bool]("publicreportQuickWithParentsCascading") publicreportQuickRelQuickPhotosCtx = newContextual[bool]("publicreport.quick.publicreport.quick_photo.publicreport.quick_photo.quick_photo_quick_id_fkey") diff --git a/db/factory/bobfactory_main.bob.go b/db/factory/bobfactory_main.bob.go index 018e83b1..d70979f9 100644 --- a/db/factory/bobfactory_main.bob.go +++ b/db/factory/bobfactory_main.bob.go @@ -58,6 +58,7 @@ type Factory struct { baseNotificationMods NotificationModSlice baseOauthTokenMods OauthTokenModSlice baseOrganizationMods OrganizationModSlice + basePublicreportNuisanceMods PublicreportNuisanceModSlice basePublicreportQuickMods PublicreportQuickModSlice basePublicreportQuickPhotoMods PublicreportQuickPhotoModSlice baseRasterColumnMods RasterColumnModSlice @@ -2372,6 +2373,53 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization return o } +func (f *Factory) NewPublicreportNuisance(mods ...PublicreportNuisanceMod) *PublicreportNuisanceTemplate { + return f.NewPublicreportNuisanceWithContext(context.Background(), mods...) +} + +func (f *Factory) NewPublicreportNuisanceWithContext(ctx context.Context, mods ...PublicreportNuisanceMod) *PublicreportNuisanceTemplate { + o := &PublicreportNuisanceTemplate{f: f} + + if f != nil { + f.basePublicreportNuisanceMods.Apply(ctx, o) + } + + PublicreportNuisanceModSlice(mods).Apply(ctx, o) + + return o +} + +func (f *Factory) FromExistingPublicreportNuisance(m *models.PublicreportNuisance) *PublicreportNuisanceTemplate { + o := &PublicreportNuisanceTemplate{f: f, alreadyPersisted: true} + + o.ID = func() int32 { return m.ID } + o.AdditionalInfo = func() string { return m.AdditionalInfo } + o.Created = func() time.Time { return m.Created } + o.Duration = func() enums.PublicreportNuisancedurationtype { return m.Duration } + o.Email = func() string { return m.Email } + o.InspectionType = func() enums.PublicreportNuisanceinspectiontype { return m.InspectionType } + o.Location = func() enums.PublicreportNuisancelocationtype { return m.Location } + o.PreferredDateRange = func() enums.PublicreportNuisancepreferreddaterangetype { return m.PreferredDateRange } + o.PreferredTime = func() enums.PublicreportNuisancepreferredtimetype { return m.PreferredTime } + o.RequestCall = func() bool { return m.RequestCall } + o.Severity = func() int16 { return m.Severity } + o.SourceContainer = func() bool { return m.SourceContainer } + o.SourceDescription = func() string { return m.SourceDescription } + o.SourceRoof = func() bool { return m.SourceRoof } + o.SourceStagnant = func() bool { return m.SourceStagnant } + o.TimeOfDayDay = func() bool { return m.TimeOfDayDay } + o.TimeOfDayEarly = func() bool { return m.TimeOfDayEarly } + o.TimeOfDayEvening = func() bool { return m.TimeOfDayEvening } + o.TimeOfDayNight = func() bool { return m.TimeOfDayNight } + o.PublicID = func() string { return m.PublicID } + o.ReporterAddress = func() string { return m.ReporterAddress } + o.ReporterEmail = func() string { return m.ReporterEmail } + o.ReporterName = func() string { return m.ReporterName } + o.ReporterPhone = func() string { return m.ReporterPhone } + + return o +} + func (f *Factory) NewPublicreportQuick(mods ...PublicreportQuickMod) *PublicreportQuickTemplate { return f.NewPublicreportQuickWithContext(context.Background(), mods...) } @@ -2953,6 +3001,14 @@ func (f *Factory) AddBaseOrganizationMod(mods ...OrganizationMod) { f.baseOrganizationMods = append(f.baseOrganizationMods, mods...) } +func (f *Factory) ClearBasePublicreportNuisanceMods() { + f.basePublicreportNuisanceMods = nil +} + +func (f *Factory) AddBasePublicreportNuisanceMod(mods ...PublicreportNuisanceMod) { + f.basePublicreportNuisanceMods = append(f.basePublicreportNuisanceMods, mods...) +} + func (f *Factory) ClearBasePublicreportQuickMods() { f.basePublicreportQuickMods = nil } diff --git a/db/factory/bobfactory_random.bob.go b/db/factory/bobfactory_random.bob.go index 3d12609f..12a17554 100644 --- a/db/factory/bobfactory_random.bob.go +++ b/db/factory/bobfactory_random.bob.go @@ -87,6 +87,56 @@ func random_enums_Notificationtype(f *faker.Faker, limits ...string) enums.Notif return all[f.IntBetween(0, len(all)-1)] } +func random_enums_PublicreportNuisancedurationtype(f *faker.Faker, limits ...string) enums.PublicreportNuisancedurationtype { + if f == nil { + f = &defaultFaker + } + + var e enums.PublicreportNuisancedurationtype + all := e.All() + return all[f.IntBetween(0, len(all)-1)] +} + +func random_enums_PublicreportNuisanceinspectiontype(f *faker.Faker, limits ...string) enums.PublicreportNuisanceinspectiontype { + if f == nil { + f = &defaultFaker + } + + var e enums.PublicreportNuisanceinspectiontype + all := e.All() + return all[f.IntBetween(0, len(all)-1)] +} + +func random_enums_PublicreportNuisancelocationtype(f *faker.Faker, limits ...string) enums.PublicreportNuisancelocationtype { + if f == nil { + f = &defaultFaker + } + + var e enums.PublicreportNuisancelocationtype + all := e.All() + return all[f.IntBetween(0, len(all)-1)] +} + +func random_enums_PublicreportNuisancepreferreddaterangetype(f *faker.Faker, limits ...string) enums.PublicreportNuisancepreferreddaterangetype { + if f == nil { + f = &defaultFaker + } + + var e enums.PublicreportNuisancepreferreddaterangetype + all := e.All() + return all[f.IntBetween(0, len(all)-1)] +} + +func random_enums_PublicreportNuisancepreferredtimetype(f *faker.Faker, limits ...string) enums.PublicreportNuisancepreferredtimetype { + if f == nil { + f = &defaultFaker + } + + var e enums.PublicreportNuisancepreferredtimetype + all := e.All() + return all[f.IntBetween(0, len(all)-1)] +} + func random_float32(f *faker.Faker, limits ...string) float32 { if f == nil { f = &defaultFaker diff --git a/db/factory/publicreport.nuisance.bob.go b/db/factory/publicreport.nuisance.bob.go new file mode 100644 index 00000000..56a77224 --- /dev/null +++ b/db/factory/publicreport.nuisance.bob.go @@ -0,0 +1,1265 @@ +// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package factory + +import ( + "context" + "testing" + "time" + + enums "github.com/Gleipnir-Technology/nidus-sync/db/enums" + models "github.com/Gleipnir-Technology/nidus-sync/db/models" + "github.com/aarondl/opt/omit" + "github.com/jaswdr/faker/v2" + "github.com/stephenafamo/bob" +) + +type PublicreportNuisanceMod interface { + Apply(context.Context, *PublicreportNuisanceTemplate) +} + +type PublicreportNuisanceModFunc func(context.Context, *PublicreportNuisanceTemplate) + +func (f PublicreportNuisanceModFunc) Apply(ctx context.Context, n *PublicreportNuisanceTemplate) { + f(ctx, n) +} + +type PublicreportNuisanceModSlice []PublicreportNuisanceMod + +func (mods PublicreportNuisanceModSlice) Apply(ctx context.Context, n *PublicreportNuisanceTemplate) { + for _, f := range mods { + f.Apply(ctx, n) + } +} + +// PublicreportNuisanceTemplate is an object representing the database table. +// all columns are optional and should be set by mods +type PublicreportNuisanceTemplate struct { + ID func() int32 + AdditionalInfo func() string + Created func() time.Time + Duration func() enums.PublicreportNuisancedurationtype + Email func() string + InspectionType func() enums.PublicreportNuisanceinspectiontype + Location func() enums.PublicreportNuisancelocationtype + PreferredDateRange func() enums.PublicreportNuisancepreferreddaterangetype + PreferredTime func() enums.PublicreportNuisancepreferredtimetype + RequestCall func() bool + Severity func() int16 + SourceContainer func() bool + SourceDescription func() string + SourceRoof func() bool + SourceStagnant func() bool + TimeOfDayDay func() bool + TimeOfDayEarly func() bool + TimeOfDayEvening func() bool + TimeOfDayNight func() bool + PublicID func() string + ReporterAddress func() string + ReporterEmail func() string + ReporterName func() string + ReporterPhone func() string + + f *Factory + + alreadyPersisted bool +} + +// Apply mods to the PublicreportNuisanceTemplate +func (o *PublicreportNuisanceTemplate) Apply(ctx context.Context, mods ...PublicreportNuisanceMod) { + for _, mod := range mods { + mod.Apply(ctx, o) + } +} + +// setModelRels creates and sets the relationships on *models.PublicreportNuisance +// according to the relationships in the template. Nothing is inserted into the db +func (t PublicreportNuisanceTemplate) setModelRels(o *models.PublicreportNuisance) {} + +// BuildSetter returns an *models.PublicreportNuisanceSetter +// this does nothing with the relationship templates +func (o PublicreportNuisanceTemplate) BuildSetter() *models.PublicreportNuisanceSetter { + m := &models.PublicreportNuisanceSetter{} + + if o.ID != nil { + val := o.ID() + m.ID = omit.From(val) + } + if o.AdditionalInfo != nil { + val := o.AdditionalInfo() + m.AdditionalInfo = omit.From(val) + } + if o.Created != nil { + val := o.Created() + m.Created = omit.From(val) + } + if o.Duration != nil { + val := o.Duration() + m.Duration = omit.From(val) + } + if o.Email != nil { + val := o.Email() + m.Email = omit.From(val) + } + if o.InspectionType != nil { + val := o.InspectionType() + m.InspectionType = omit.From(val) + } + if o.Location != nil { + val := o.Location() + m.Location = omit.From(val) + } + if o.PreferredDateRange != nil { + val := o.PreferredDateRange() + m.PreferredDateRange = omit.From(val) + } + if o.PreferredTime != nil { + val := o.PreferredTime() + m.PreferredTime = omit.From(val) + } + if o.RequestCall != nil { + val := o.RequestCall() + m.RequestCall = omit.From(val) + } + if o.Severity != nil { + val := o.Severity() + m.Severity = omit.From(val) + } + if o.SourceContainer != nil { + val := o.SourceContainer() + m.SourceContainer = omit.From(val) + } + if o.SourceDescription != nil { + val := o.SourceDescription() + m.SourceDescription = omit.From(val) + } + if o.SourceRoof != nil { + val := o.SourceRoof() + m.SourceRoof = omit.From(val) + } + if o.SourceStagnant != nil { + val := o.SourceStagnant() + m.SourceStagnant = omit.From(val) + } + if o.TimeOfDayDay != nil { + val := o.TimeOfDayDay() + m.TimeOfDayDay = omit.From(val) + } + if o.TimeOfDayEarly != nil { + val := o.TimeOfDayEarly() + m.TimeOfDayEarly = omit.From(val) + } + if o.TimeOfDayEvening != nil { + val := o.TimeOfDayEvening() + m.TimeOfDayEvening = omit.From(val) + } + if o.TimeOfDayNight != nil { + val := o.TimeOfDayNight() + m.TimeOfDayNight = omit.From(val) + } + if o.PublicID != nil { + val := o.PublicID() + m.PublicID = omit.From(val) + } + if o.ReporterAddress != nil { + val := o.ReporterAddress() + m.ReporterAddress = omit.From(val) + } + if o.ReporterEmail != nil { + val := o.ReporterEmail() + m.ReporterEmail = omit.From(val) + } + if o.ReporterName != nil { + val := o.ReporterName() + m.ReporterName = omit.From(val) + } + if o.ReporterPhone != nil { + val := o.ReporterPhone() + m.ReporterPhone = omit.From(val) + } + + return m +} + +// BuildManySetter returns an []*models.PublicreportNuisanceSetter +// this does nothing with the relationship templates +func (o PublicreportNuisanceTemplate) BuildManySetter(number int) []*models.PublicreportNuisanceSetter { + m := make([]*models.PublicreportNuisanceSetter, number) + + for i := range m { + m[i] = o.BuildSetter() + } + + return m +} + +// Build returns an *models.PublicreportNuisance +// Related objects are also created and placed in the .R field +// NOTE: Objects are not inserted into the database. Use PublicreportNuisanceTemplate.Create +func (o PublicreportNuisanceTemplate) Build() *models.PublicreportNuisance { + m := &models.PublicreportNuisance{} + + if o.ID != nil { + m.ID = o.ID() + } + if o.AdditionalInfo != nil { + m.AdditionalInfo = o.AdditionalInfo() + } + if o.Created != nil { + m.Created = o.Created() + } + if o.Duration != nil { + m.Duration = o.Duration() + } + if o.Email != nil { + m.Email = o.Email() + } + if o.InspectionType != nil { + m.InspectionType = o.InspectionType() + } + if o.Location != nil { + m.Location = o.Location() + } + if o.PreferredDateRange != nil { + m.PreferredDateRange = o.PreferredDateRange() + } + if o.PreferredTime != nil { + m.PreferredTime = o.PreferredTime() + } + if o.RequestCall != nil { + m.RequestCall = o.RequestCall() + } + if o.Severity != nil { + m.Severity = o.Severity() + } + if o.SourceContainer != nil { + m.SourceContainer = o.SourceContainer() + } + if o.SourceDescription != nil { + m.SourceDescription = o.SourceDescription() + } + if o.SourceRoof != nil { + m.SourceRoof = o.SourceRoof() + } + if o.SourceStagnant != nil { + m.SourceStagnant = o.SourceStagnant() + } + if o.TimeOfDayDay != nil { + m.TimeOfDayDay = o.TimeOfDayDay() + } + if o.TimeOfDayEarly != nil { + m.TimeOfDayEarly = o.TimeOfDayEarly() + } + if o.TimeOfDayEvening != nil { + m.TimeOfDayEvening = o.TimeOfDayEvening() + } + if o.TimeOfDayNight != nil { + m.TimeOfDayNight = o.TimeOfDayNight() + } + if o.PublicID != nil { + m.PublicID = o.PublicID() + } + if o.ReporterAddress != nil { + m.ReporterAddress = o.ReporterAddress() + } + if o.ReporterEmail != nil { + m.ReporterEmail = o.ReporterEmail() + } + if o.ReporterName != nil { + m.ReporterName = o.ReporterName() + } + if o.ReporterPhone != nil { + m.ReporterPhone = o.ReporterPhone() + } + + o.setModelRels(m) + + return m +} + +// BuildMany returns an models.PublicreportNuisanceSlice +// Related objects are also created and placed in the .R field +// NOTE: Objects are not inserted into the database. Use PublicreportNuisanceTemplate.CreateMany +func (o PublicreportNuisanceTemplate) BuildMany(number int) models.PublicreportNuisanceSlice { + m := make(models.PublicreportNuisanceSlice, number) + + for i := range m { + m[i] = o.Build() + } + + return m +} + +func ensureCreatablePublicreportNuisance(m *models.PublicreportNuisanceSetter) { + if !(m.AdditionalInfo.IsValue()) { + val := random_string(nil) + m.AdditionalInfo = omit.From(val) + } + if !(m.Created.IsValue()) { + val := random_time_Time(nil) + m.Created = omit.From(val) + } + if !(m.Duration.IsValue()) { + val := random_enums_PublicreportNuisancedurationtype(nil) + m.Duration = omit.From(val) + } + if !(m.Email.IsValue()) { + val := random_string(nil) + m.Email = omit.From(val) + } + if !(m.InspectionType.IsValue()) { + val := random_enums_PublicreportNuisanceinspectiontype(nil) + m.InspectionType = omit.From(val) + } + if !(m.Location.IsValue()) { + val := random_enums_PublicreportNuisancelocationtype(nil) + m.Location = omit.From(val) + } + if !(m.PreferredDateRange.IsValue()) { + val := random_enums_PublicreportNuisancepreferreddaterangetype(nil) + m.PreferredDateRange = omit.From(val) + } + if !(m.PreferredTime.IsValue()) { + val := random_enums_PublicreportNuisancepreferredtimetype(nil) + m.PreferredTime = omit.From(val) + } + if !(m.RequestCall.IsValue()) { + val := random_bool(nil) + m.RequestCall = omit.From(val) + } + if !(m.Severity.IsValue()) { + val := random_int16(nil) + m.Severity = omit.From(val) + } + if !(m.SourceContainer.IsValue()) { + val := random_bool(nil) + m.SourceContainer = omit.From(val) + } + if !(m.SourceDescription.IsValue()) { + val := random_string(nil) + m.SourceDescription = omit.From(val) + } + if !(m.SourceRoof.IsValue()) { + val := random_bool(nil) + m.SourceRoof = omit.From(val) + } + if !(m.SourceStagnant.IsValue()) { + val := random_bool(nil) + m.SourceStagnant = omit.From(val) + } + if !(m.TimeOfDayDay.IsValue()) { + val := random_bool(nil) + m.TimeOfDayDay = omit.From(val) + } + if !(m.TimeOfDayEarly.IsValue()) { + val := random_bool(nil) + m.TimeOfDayEarly = omit.From(val) + } + if !(m.TimeOfDayEvening.IsValue()) { + val := random_bool(nil) + m.TimeOfDayEvening = omit.From(val) + } + if !(m.TimeOfDayNight.IsValue()) { + val := random_bool(nil) + m.TimeOfDayNight = omit.From(val) + } + if !(m.PublicID.IsValue()) { + val := random_string(nil) + m.PublicID = omit.From(val) + } + if !(m.ReporterAddress.IsValue()) { + val := random_string(nil) + m.ReporterAddress = omit.From(val) + } + if !(m.ReporterEmail.IsValue()) { + val := random_string(nil) + m.ReporterEmail = omit.From(val) + } + if !(m.ReporterName.IsValue()) { + val := random_string(nil) + m.ReporterName = omit.From(val) + } + if !(m.ReporterPhone.IsValue()) { + val := random_string(nil) + m.ReporterPhone = omit.From(val) + } +} + +// insertOptRels creates and inserts any optional the relationships on *models.PublicreportNuisance +// according to the relationships in the template. +// any required relationship should have already exist on the model +func (o *PublicreportNuisanceTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportNuisance) error { + var err error + + return err +} + +// Create builds a publicreportNuisance and inserts it into the database +// Relations objects are also inserted and placed in the .R field +func (o *PublicreportNuisanceTemplate) Create(ctx context.Context, exec bob.Executor) (*models.PublicreportNuisance, error) { + var err error + opt := o.BuildSetter() + ensureCreatablePublicreportNuisance(opt) + + m, err := models.PublicreportNuisances.Insert(opt).One(ctx, exec) + if err != nil { + return nil, err + } + + if err := o.insertOptRels(ctx, exec, m); err != nil { + return nil, err + } + return m, err +} + +// MustCreate builds a publicreportNuisance and inserts it into the database +// Relations objects are also inserted and placed in the .R field +// panics if an error occurs +func (o *PublicreportNuisanceTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.PublicreportNuisance { + m, err := o.Create(ctx, exec) + if err != nil { + panic(err) + } + return m +} + +// CreateOrFail builds a publicreportNuisance and inserts it into the database +// Relations objects are also inserted and placed in the .R field +// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs +func (o *PublicreportNuisanceTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.PublicreportNuisance { + tb.Helper() + m, err := o.Create(ctx, exec) + if err != nil { + tb.Fatal(err) + return nil + } + return m +} + +// CreateMany builds multiple publicreportNuisances and inserts them into the database +// Relations objects are also inserted and placed in the .R field +func (o PublicreportNuisanceTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.PublicreportNuisanceSlice, error) { + var err error + m := make(models.PublicreportNuisanceSlice, number) + + for i := range m { + m[i], err = o.Create(ctx, exec) + if err != nil { + return nil, err + } + } + + return m, nil +} + +// MustCreateMany builds multiple publicreportNuisances and inserts them into the database +// Relations objects are also inserted and placed in the .R field +// panics if an error occurs +func (o PublicreportNuisanceTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.PublicreportNuisanceSlice { + m, err := o.CreateMany(ctx, exec, number) + if err != nil { + panic(err) + } + return m +} + +// CreateManyOrFail builds multiple publicreportNuisances and inserts them into the database +// Relations objects are also inserted and placed in the .R field +// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs +func (o PublicreportNuisanceTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.PublicreportNuisanceSlice { + tb.Helper() + m, err := o.CreateMany(ctx, exec, number) + if err != nil { + tb.Fatal(err) + return nil + } + return m +} + +// PublicreportNuisance has methods that act as mods for the PublicreportNuisanceTemplate +var PublicreportNuisanceMods publicreportNuisanceMods + +type publicreportNuisanceMods struct{} + +func (m publicreportNuisanceMods) RandomizeAllColumns(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModSlice{ + PublicreportNuisanceMods.RandomID(f), + PublicreportNuisanceMods.RandomAdditionalInfo(f), + PublicreportNuisanceMods.RandomCreated(f), + PublicreportNuisanceMods.RandomDuration(f), + PublicreportNuisanceMods.RandomEmail(f), + PublicreportNuisanceMods.RandomInspectionType(f), + PublicreportNuisanceMods.RandomLocation(f), + PublicreportNuisanceMods.RandomPreferredDateRange(f), + PublicreportNuisanceMods.RandomPreferredTime(f), + PublicreportNuisanceMods.RandomRequestCall(f), + PublicreportNuisanceMods.RandomSeverity(f), + PublicreportNuisanceMods.RandomSourceContainer(f), + PublicreportNuisanceMods.RandomSourceDescription(f), + PublicreportNuisanceMods.RandomSourceRoof(f), + PublicreportNuisanceMods.RandomSourceStagnant(f), + PublicreportNuisanceMods.RandomTimeOfDayDay(f), + PublicreportNuisanceMods.RandomTimeOfDayEarly(f), + PublicreportNuisanceMods.RandomTimeOfDayEvening(f), + PublicreportNuisanceMods.RandomTimeOfDayNight(f), + PublicreportNuisanceMods.RandomPublicID(f), + PublicreportNuisanceMods.RandomReporterAddress(f), + PublicreportNuisanceMods.RandomReporterEmail(f), + PublicreportNuisanceMods.RandomReporterName(f), + PublicreportNuisanceMods.RandomReporterPhone(f), + } +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) ID(val int32) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ID = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) IDFunc(f func() int32) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ID = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetID() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ID = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomID(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ID = func() int32 { + return random_int32(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) AdditionalInfo(val string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.AdditionalInfo = func() string { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) AdditionalInfoFunc(f func() string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.AdditionalInfo = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetAdditionalInfo() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.AdditionalInfo = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomAdditionalInfo(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.AdditionalInfo = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) Created(val time.Time) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Created = func() time.Time { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) CreatedFunc(f func() time.Time) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Created = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetCreated() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Created = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomCreated(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Created = func() time.Time { + return random_time_Time(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) Duration(val enums.PublicreportNuisancedurationtype) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Duration = func() enums.PublicreportNuisancedurationtype { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) DurationFunc(f func() enums.PublicreportNuisancedurationtype) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Duration = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetDuration() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Duration = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomDuration(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Duration = func() enums.PublicreportNuisancedurationtype { + return random_enums_PublicreportNuisancedurationtype(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) Email(val string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Email = func() string { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) EmailFunc(f func() string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Email = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetEmail() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Email = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomEmail(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Email = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) InspectionType(val enums.PublicreportNuisanceinspectiontype) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.InspectionType = func() enums.PublicreportNuisanceinspectiontype { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) InspectionTypeFunc(f func() enums.PublicreportNuisanceinspectiontype) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.InspectionType = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetInspectionType() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.InspectionType = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomInspectionType(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.InspectionType = func() enums.PublicreportNuisanceinspectiontype { + return random_enums_PublicreportNuisanceinspectiontype(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) Location(val enums.PublicreportNuisancelocationtype) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Location = func() enums.PublicreportNuisancelocationtype { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) LocationFunc(f func() enums.PublicreportNuisancelocationtype) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Location = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetLocation() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Location = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomLocation(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Location = func() enums.PublicreportNuisancelocationtype { + return random_enums_PublicreportNuisancelocationtype(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) PreferredDateRange(val enums.PublicreportNuisancepreferreddaterangetype) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PreferredDateRange = func() enums.PublicreportNuisancepreferreddaterangetype { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) PreferredDateRangeFunc(f func() enums.PublicreportNuisancepreferreddaterangetype) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PreferredDateRange = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetPreferredDateRange() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PreferredDateRange = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomPreferredDateRange(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PreferredDateRange = func() enums.PublicreportNuisancepreferreddaterangetype { + return random_enums_PublicreportNuisancepreferreddaterangetype(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) PreferredTime(val enums.PublicreportNuisancepreferredtimetype) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PreferredTime = func() enums.PublicreportNuisancepreferredtimetype { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) PreferredTimeFunc(f func() enums.PublicreportNuisancepreferredtimetype) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PreferredTime = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetPreferredTime() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PreferredTime = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomPreferredTime(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PreferredTime = func() enums.PublicreportNuisancepreferredtimetype { + return random_enums_PublicreportNuisancepreferredtimetype(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) RequestCall(val bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.RequestCall = func() bool { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) RequestCallFunc(f func() bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.RequestCall = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetRequestCall() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.RequestCall = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomRequestCall(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.RequestCall = func() bool { + return random_bool(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) Severity(val int16) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Severity = func() int16 { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) SeverityFunc(f func() int16) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Severity = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetSeverity() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Severity = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomSeverity(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.Severity = func() int16 { + return random_int16(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) SourceContainer(val bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceContainer = func() bool { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) SourceContainerFunc(f func() bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceContainer = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetSourceContainer() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceContainer = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomSourceContainer(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceContainer = func() bool { + return random_bool(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) SourceDescription(val string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceDescription = func() string { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) SourceDescriptionFunc(f func() string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceDescription = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetSourceDescription() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceDescription = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomSourceDescription(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceDescription = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) SourceRoof(val bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceRoof = func() bool { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) SourceRoofFunc(f func() bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceRoof = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetSourceRoof() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceRoof = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomSourceRoof(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceRoof = func() bool { + return random_bool(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) SourceStagnant(val bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceStagnant = func() bool { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) SourceStagnantFunc(f func() bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceStagnant = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetSourceStagnant() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceStagnant = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomSourceStagnant(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.SourceStagnant = func() bool { + return random_bool(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) TimeOfDayDay(val bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayDay = func() bool { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) TimeOfDayDayFunc(f func() bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayDay = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetTimeOfDayDay() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayDay = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomTimeOfDayDay(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayDay = func() bool { + return random_bool(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) TimeOfDayEarly(val bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayEarly = func() bool { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) TimeOfDayEarlyFunc(f func() bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayEarly = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetTimeOfDayEarly() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayEarly = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomTimeOfDayEarly(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayEarly = func() bool { + return random_bool(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) TimeOfDayEvening(val bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayEvening = func() bool { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) TimeOfDayEveningFunc(f func() bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayEvening = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetTimeOfDayEvening() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayEvening = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomTimeOfDayEvening(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayEvening = func() bool { + return random_bool(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) TimeOfDayNight(val bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayNight = func() bool { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) TimeOfDayNightFunc(f func() bool) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayNight = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetTimeOfDayNight() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayNight = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomTimeOfDayNight(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.TimeOfDayNight = func() bool { + return random_bool(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) PublicID(val string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PublicID = func() string { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) PublicIDFunc(f func() string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PublicID = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetPublicID() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PublicID = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomPublicID(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.PublicID = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) ReporterAddress(val string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterAddress = func() string { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) ReporterAddressFunc(f func() string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterAddress = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetReporterAddress() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterAddress = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomReporterAddress(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterAddress = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) ReporterEmail(val string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterEmail = func() string { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) ReporterEmailFunc(f func() string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterEmail = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetReporterEmail() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterEmail = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomReporterEmail(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterEmail = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) ReporterName(val string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterName = func() string { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) ReporterNameFunc(f func() string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterName = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetReporterName() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterName = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomReporterName(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterName = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m publicreportNuisanceMods) ReporterPhone(val string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterPhone = func() string { return val } + }) +} + +// Set the Column from the function +func (m publicreportNuisanceMods) ReporterPhoneFunc(f func() string) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterPhone = f + }) +} + +// Clear any values for the column +func (m publicreportNuisanceMods) UnsetReporterPhone() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterPhone = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m publicreportNuisanceMods) RandomReporterPhone(f *faker.Faker) PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) { + o.ReporterPhone = func() string { + return random_string(f) + } + }) +} + +func (m publicreportNuisanceMods) WithParentsCascading() PublicreportNuisanceMod { + return PublicreportNuisanceModFunc(func(ctx context.Context, o *PublicreportNuisanceTemplate) { + if isDone, _ := publicreportNuisanceWithParentsCascadingCtx.Value(ctx); isDone { + return + } + ctx = publicreportNuisanceWithParentsCascadingCtx.WithValue(ctx, true) + }) +} diff --git a/db/migrations/00025_public_nuisance.sql b/db/migrations/00025_public_nuisance.sql new file mode 100644 index 00000000..3e3e1427 --- /dev/null +++ b/db/migrations/00025_public_nuisance.sql @@ -0,0 +1,71 @@ +-- +goose Up +CREATE TYPE publicreport.NuisanceDurationType AS ENUM ( + 'none', + 'just-noticed', + 'few-days', + '1-2-weeks', + '2-4-weeks', + '1-3-months', + 'seasonal' +); +CREATE TYPE publicreport.NuisanceLocationType AS ENUM ( + 'none', + 'front-yard', + 'backyard', + 'patio', + 'garden', + 'pool-area', + 'throughout', + 'indoors', + 'other' +); +CREATE TYPE publicreport.NuisanceInspectionType AS ENUM ( + 'neighborhood', + 'property' +); +CREATE TYPE publicreport.NuisancePreferredDateRangeType AS ENUM ( + 'none', + 'any-time', + 'in-two-weeks', + 'next-week' +); +CREATE TYPE publicreport.NuisancePreferredTimeType AS ENUM ( + 'none', + 'afternoon', + 'any-time', + 'morning' +); +CREATE TABLE publicreport.nuisance ( + id SERIAL PRIMARY KEY, + additional_info TEXT NOT NULL, + created TIMESTAMP WITHOUT TIME ZONE NOT NULL, + duration publicreport.NuisanceDurationType NOT NULL, + email TEXT NOT NULL, + inspection_type publicreport.NuisanceInspectionType NOT NULL, + location publicreport.NuisanceLocationType NOT NULL, + preferred_date_range publicreport.NuisancePreferredDateRangeType NOT NULL, + preferred_time publicreport.NuisancePreferredTimeType NOT NULL, + request_call BOOLEAN NOT NULL, + severity SMALLINT NOT NULL, + source_container BOOLEAN NOT NULL, + source_description TEXT NOT NULL, + source_roof BOOLEAN NOT NULL, + source_stagnant BOOLEAN NOT NULL, + time_of_day_day BOOLEAN NOT NULL, + time_of_day_early BOOLEAN NOT NULL, + time_of_day_evening BOOLEAN NOT NULL, + time_of_day_night BOOLEAN NOT NULL, + public_id TEXT NOT NULL UNIQUE, + reporter_address TEXT NOT NULL, + reporter_email TEXT NOT NULL, + reporter_name TEXT NOT NULL, + reporter_phone TEXT NOT NULL +); + +-- +goose Down +DROP TABLE publicreport.nuisance; +DROP TYPE publicreport.NuisanceDurationType; +DROP TYPE publicreport.NuisanceLocationType; +DROP TYPE publicreport.NuisanceInspectionType; +DROP TYPE publicreport.NuisancePreferredDateRangeType; +DROP TYPE publicreport.NuisancePreferredTimeType; diff --git a/db/models/bob_where.bob.go b/db/models/bob_where.bob.go index 9b596bb1..fb639108 100644 --- a/db/models/bob_where.bob.go +++ b/db/models/bob_where.bob.go @@ -58,6 +58,7 @@ func Where[Q psql.Filterable]() struct { Notifications notificationWhere[Q] OauthTokens oauthTokenWhere[Q] Organizations organizationWhere[Q] + PublicreportNuisances publicreportNuisanceWhere[Q] PublicreportQuicks publicreportQuickWhere[Q] PublicreportQuickPhotos publicreportQuickPhotoWhere[Q] RasterColumns rasterColumnWhere[Q] @@ -108,6 +109,7 @@ func Where[Q psql.Filterable]() struct { Notifications notificationWhere[Q] OauthTokens oauthTokenWhere[Q] Organizations organizationWhere[Q] + PublicreportNuisances publicreportNuisanceWhere[Q] PublicreportQuicks publicreportQuickWhere[Q] PublicreportQuickPhotos publicreportQuickPhotoWhere[Q] RasterColumns rasterColumnWhere[Q] @@ -157,6 +159,7 @@ func Where[Q psql.Filterable]() struct { Notifications: buildNotificationWhere[Q](Notifications.Columns), OauthTokens: buildOauthTokenWhere[Q](OauthTokens.Columns), Organizations: buildOrganizationWhere[Q](Organizations.Columns), + PublicreportNuisances: buildPublicreportNuisanceWhere[Q](PublicreportNuisances.Columns), PublicreportQuicks: buildPublicreportQuickWhere[Q](PublicreportQuicks.Columns), PublicreportQuickPhotos: buildPublicreportQuickPhotoWhere[Q](PublicreportQuickPhotos.Columns), RasterColumns: buildRasterColumnWhere[Q](RasterColumns.Columns), diff --git a/db/models/publicreport.nuisance.bob.go b/db/models/publicreport.nuisance.bob.go new file mode 100644 index 00000000..8a815325 --- /dev/null +++ b/db/models/publicreport.nuisance.bob.go @@ -0,0 +1,925 @@ +// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package models + +import ( + "context" + "io" + "time" + + enums "github.com/Gleipnir-Technology/nidus-sync/db/enums" + "github.com/aarondl/opt/omit" + "github.com/stephenafamo/bob" + "github.com/stephenafamo/bob/dialect/psql" + "github.com/stephenafamo/bob/dialect/psql/dialect" + "github.com/stephenafamo/bob/dialect/psql/dm" + "github.com/stephenafamo/bob/dialect/psql/sm" + "github.com/stephenafamo/bob/dialect/psql/um" + "github.com/stephenafamo/bob/expr" +) + +// PublicreportNuisance is an object representing the database table. +type PublicreportNuisance struct { + ID int32 `db:"id,pk" ` + AdditionalInfo string `db:"additional_info" ` + Created time.Time `db:"created" ` + Duration enums.PublicreportNuisancedurationtype `db:"duration" ` + Email string `db:"email" ` + InspectionType enums.PublicreportNuisanceinspectiontype `db:"inspection_type" ` + Location enums.PublicreportNuisancelocationtype `db:"location" ` + PreferredDateRange enums.PublicreportNuisancepreferreddaterangetype `db:"preferred_date_range" ` + PreferredTime enums.PublicreportNuisancepreferredtimetype `db:"preferred_time" ` + RequestCall bool `db:"request_call" ` + Severity int16 `db:"severity" ` + SourceContainer bool `db:"source_container" ` + SourceDescription string `db:"source_description" ` + SourceRoof bool `db:"source_roof" ` + SourceStagnant bool `db:"source_stagnant" ` + TimeOfDayDay bool `db:"time_of_day_day" ` + TimeOfDayEarly bool `db:"time_of_day_early" ` + TimeOfDayEvening bool `db:"time_of_day_evening" ` + TimeOfDayNight bool `db:"time_of_day_night" ` + PublicID string `db:"public_id" ` + ReporterAddress string `db:"reporter_address" ` + ReporterEmail string `db:"reporter_email" ` + ReporterName string `db:"reporter_name" ` + ReporterPhone string `db:"reporter_phone" ` +} + +// PublicreportNuisanceSlice is an alias for a slice of pointers to PublicreportNuisance. +// This should almost always be used instead of []*PublicreportNuisance. +type PublicreportNuisanceSlice []*PublicreportNuisance + +// PublicreportNuisances contains methods to work with the nuisance table +var PublicreportNuisances = psql.NewTablex[*PublicreportNuisance, PublicreportNuisanceSlice, *PublicreportNuisanceSetter]("publicreport", "nuisance", buildPublicreportNuisanceColumns("publicreport.nuisance")) + +// PublicreportNuisancesQuery is a query on the nuisance table +type PublicreportNuisancesQuery = *psql.ViewQuery[*PublicreportNuisance, PublicreportNuisanceSlice] + +func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns { + return publicreportNuisanceColumns{ + ColumnsExpr: expr.NewColumnsExpr( + "id", "additional_info", "created", "duration", "email", "inspection_type", "location", "preferred_date_range", "preferred_time", "request_call", "severity", "source_container", "source_description", "source_roof", "source_stagnant", "time_of_day_day", "time_of_day_early", "time_of_day_evening", "time_of_day_night", "public_id", "reporter_address", "reporter_email", "reporter_name", "reporter_phone", + ).WithParent("publicreport.nuisance"), + tableAlias: alias, + ID: psql.Quote(alias, "id"), + AdditionalInfo: psql.Quote(alias, "additional_info"), + Created: psql.Quote(alias, "created"), + Duration: psql.Quote(alias, "duration"), + Email: psql.Quote(alias, "email"), + InspectionType: psql.Quote(alias, "inspection_type"), + Location: psql.Quote(alias, "location"), + PreferredDateRange: psql.Quote(alias, "preferred_date_range"), + PreferredTime: psql.Quote(alias, "preferred_time"), + RequestCall: psql.Quote(alias, "request_call"), + Severity: psql.Quote(alias, "severity"), + SourceContainer: psql.Quote(alias, "source_container"), + SourceDescription: psql.Quote(alias, "source_description"), + SourceRoof: psql.Quote(alias, "source_roof"), + SourceStagnant: psql.Quote(alias, "source_stagnant"), + TimeOfDayDay: psql.Quote(alias, "time_of_day_day"), + TimeOfDayEarly: psql.Quote(alias, "time_of_day_early"), + TimeOfDayEvening: psql.Quote(alias, "time_of_day_evening"), + TimeOfDayNight: psql.Quote(alias, "time_of_day_night"), + PublicID: psql.Quote(alias, "public_id"), + ReporterAddress: psql.Quote(alias, "reporter_address"), + ReporterEmail: psql.Quote(alias, "reporter_email"), + ReporterName: psql.Quote(alias, "reporter_name"), + ReporterPhone: psql.Quote(alias, "reporter_phone"), + } +} + +type publicreportNuisanceColumns struct { + expr.ColumnsExpr + tableAlias string + ID psql.Expression + AdditionalInfo psql.Expression + Created psql.Expression + Duration psql.Expression + Email psql.Expression + InspectionType psql.Expression + Location psql.Expression + PreferredDateRange psql.Expression + PreferredTime psql.Expression + RequestCall psql.Expression + Severity psql.Expression + SourceContainer psql.Expression + SourceDescription psql.Expression + SourceRoof psql.Expression + SourceStagnant psql.Expression + TimeOfDayDay psql.Expression + TimeOfDayEarly psql.Expression + TimeOfDayEvening psql.Expression + TimeOfDayNight psql.Expression + PublicID psql.Expression + ReporterAddress psql.Expression + ReporterEmail psql.Expression + ReporterName psql.Expression + ReporterPhone psql.Expression +} + +func (c publicreportNuisanceColumns) Alias() string { + return c.tableAlias +} + +func (publicreportNuisanceColumns) AliasedAs(alias string) publicreportNuisanceColumns { + return buildPublicreportNuisanceColumns(alias) +} + +// PublicreportNuisanceSetter is used for insert/upsert/update operations +// All values are optional, and do not have to be set +// Generated columns are not included +type PublicreportNuisanceSetter struct { + ID omit.Val[int32] `db:"id,pk" ` + AdditionalInfo omit.Val[string] `db:"additional_info" ` + Created omit.Val[time.Time] `db:"created" ` + Duration omit.Val[enums.PublicreportNuisancedurationtype] `db:"duration" ` + Email omit.Val[string] `db:"email" ` + InspectionType omit.Val[enums.PublicreportNuisanceinspectiontype] `db:"inspection_type" ` + Location omit.Val[enums.PublicreportNuisancelocationtype] `db:"location" ` + PreferredDateRange omit.Val[enums.PublicreportNuisancepreferreddaterangetype] `db:"preferred_date_range" ` + PreferredTime omit.Val[enums.PublicreportNuisancepreferredtimetype] `db:"preferred_time" ` + RequestCall omit.Val[bool] `db:"request_call" ` + Severity omit.Val[int16] `db:"severity" ` + SourceContainer omit.Val[bool] `db:"source_container" ` + SourceDescription omit.Val[string] `db:"source_description" ` + SourceRoof omit.Val[bool] `db:"source_roof" ` + SourceStagnant omit.Val[bool] `db:"source_stagnant" ` + TimeOfDayDay omit.Val[bool] `db:"time_of_day_day" ` + TimeOfDayEarly omit.Val[bool] `db:"time_of_day_early" ` + TimeOfDayEvening omit.Val[bool] `db:"time_of_day_evening" ` + TimeOfDayNight omit.Val[bool] `db:"time_of_day_night" ` + PublicID omit.Val[string] `db:"public_id" ` + ReporterAddress omit.Val[string] `db:"reporter_address" ` + ReporterEmail omit.Val[string] `db:"reporter_email" ` + ReporterName omit.Val[string] `db:"reporter_name" ` + ReporterPhone omit.Val[string] `db:"reporter_phone" ` +} + +func (s PublicreportNuisanceSetter) SetColumns() []string { + vals := make([]string, 0, 24) + if s.ID.IsValue() { + vals = append(vals, "id") + } + if s.AdditionalInfo.IsValue() { + vals = append(vals, "additional_info") + } + if s.Created.IsValue() { + vals = append(vals, "created") + } + if s.Duration.IsValue() { + vals = append(vals, "duration") + } + if s.Email.IsValue() { + vals = append(vals, "email") + } + if s.InspectionType.IsValue() { + vals = append(vals, "inspection_type") + } + if s.Location.IsValue() { + vals = append(vals, "location") + } + if s.PreferredDateRange.IsValue() { + vals = append(vals, "preferred_date_range") + } + if s.PreferredTime.IsValue() { + vals = append(vals, "preferred_time") + } + if s.RequestCall.IsValue() { + vals = append(vals, "request_call") + } + if s.Severity.IsValue() { + vals = append(vals, "severity") + } + if s.SourceContainer.IsValue() { + vals = append(vals, "source_container") + } + if s.SourceDescription.IsValue() { + vals = append(vals, "source_description") + } + if s.SourceRoof.IsValue() { + vals = append(vals, "source_roof") + } + if s.SourceStagnant.IsValue() { + vals = append(vals, "source_stagnant") + } + if s.TimeOfDayDay.IsValue() { + vals = append(vals, "time_of_day_day") + } + if s.TimeOfDayEarly.IsValue() { + vals = append(vals, "time_of_day_early") + } + if s.TimeOfDayEvening.IsValue() { + vals = append(vals, "time_of_day_evening") + } + if s.TimeOfDayNight.IsValue() { + vals = append(vals, "time_of_day_night") + } + if s.PublicID.IsValue() { + vals = append(vals, "public_id") + } + if s.ReporterAddress.IsValue() { + vals = append(vals, "reporter_address") + } + if s.ReporterEmail.IsValue() { + vals = append(vals, "reporter_email") + } + if s.ReporterName.IsValue() { + vals = append(vals, "reporter_name") + } + if s.ReporterPhone.IsValue() { + vals = append(vals, "reporter_phone") + } + return vals +} + +func (s PublicreportNuisanceSetter) Overwrite(t *PublicreportNuisance) { + if s.ID.IsValue() { + t.ID = s.ID.MustGet() + } + if s.AdditionalInfo.IsValue() { + t.AdditionalInfo = s.AdditionalInfo.MustGet() + } + if s.Created.IsValue() { + t.Created = s.Created.MustGet() + } + if s.Duration.IsValue() { + t.Duration = s.Duration.MustGet() + } + if s.Email.IsValue() { + t.Email = s.Email.MustGet() + } + if s.InspectionType.IsValue() { + t.InspectionType = s.InspectionType.MustGet() + } + if s.Location.IsValue() { + t.Location = s.Location.MustGet() + } + if s.PreferredDateRange.IsValue() { + t.PreferredDateRange = s.PreferredDateRange.MustGet() + } + if s.PreferredTime.IsValue() { + t.PreferredTime = s.PreferredTime.MustGet() + } + if s.RequestCall.IsValue() { + t.RequestCall = s.RequestCall.MustGet() + } + if s.Severity.IsValue() { + t.Severity = s.Severity.MustGet() + } + if s.SourceContainer.IsValue() { + t.SourceContainer = s.SourceContainer.MustGet() + } + if s.SourceDescription.IsValue() { + t.SourceDescription = s.SourceDescription.MustGet() + } + if s.SourceRoof.IsValue() { + t.SourceRoof = s.SourceRoof.MustGet() + } + if s.SourceStagnant.IsValue() { + t.SourceStagnant = s.SourceStagnant.MustGet() + } + if s.TimeOfDayDay.IsValue() { + t.TimeOfDayDay = s.TimeOfDayDay.MustGet() + } + if s.TimeOfDayEarly.IsValue() { + t.TimeOfDayEarly = s.TimeOfDayEarly.MustGet() + } + if s.TimeOfDayEvening.IsValue() { + t.TimeOfDayEvening = s.TimeOfDayEvening.MustGet() + } + if s.TimeOfDayNight.IsValue() { + t.TimeOfDayNight = s.TimeOfDayNight.MustGet() + } + if s.PublicID.IsValue() { + t.PublicID = s.PublicID.MustGet() + } + if s.ReporterAddress.IsValue() { + t.ReporterAddress = s.ReporterAddress.MustGet() + } + if s.ReporterEmail.IsValue() { + t.ReporterEmail = s.ReporterEmail.MustGet() + } + if s.ReporterName.IsValue() { + t.ReporterName = s.ReporterName.MustGet() + } + if s.ReporterPhone.IsValue() { + t.ReporterPhone = s.ReporterPhone.MustGet() + } +} + +func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) { + q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { + return PublicreportNuisances.BeforeInsertHooks.RunHooks(ctx, exec, s) + }) + + q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + vals := make([]bob.Expression, 24) + if s.ID.IsValue() { + vals[0] = psql.Arg(s.ID.MustGet()) + } else { + vals[0] = psql.Raw("DEFAULT") + } + + if s.AdditionalInfo.IsValue() { + vals[1] = psql.Arg(s.AdditionalInfo.MustGet()) + } else { + vals[1] = psql.Raw("DEFAULT") + } + + if s.Created.IsValue() { + vals[2] = psql.Arg(s.Created.MustGet()) + } else { + vals[2] = psql.Raw("DEFAULT") + } + + if s.Duration.IsValue() { + vals[3] = psql.Arg(s.Duration.MustGet()) + } else { + vals[3] = psql.Raw("DEFAULT") + } + + if s.Email.IsValue() { + vals[4] = psql.Arg(s.Email.MustGet()) + } else { + vals[4] = psql.Raw("DEFAULT") + } + + if s.InspectionType.IsValue() { + vals[5] = psql.Arg(s.InspectionType.MustGet()) + } else { + vals[5] = psql.Raw("DEFAULT") + } + + if s.Location.IsValue() { + vals[6] = psql.Arg(s.Location.MustGet()) + } else { + vals[6] = psql.Raw("DEFAULT") + } + + if s.PreferredDateRange.IsValue() { + vals[7] = psql.Arg(s.PreferredDateRange.MustGet()) + } else { + vals[7] = psql.Raw("DEFAULT") + } + + if s.PreferredTime.IsValue() { + vals[8] = psql.Arg(s.PreferredTime.MustGet()) + } else { + vals[8] = psql.Raw("DEFAULT") + } + + if s.RequestCall.IsValue() { + vals[9] = psql.Arg(s.RequestCall.MustGet()) + } else { + vals[9] = psql.Raw("DEFAULT") + } + + if s.Severity.IsValue() { + vals[10] = psql.Arg(s.Severity.MustGet()) + } else { + vals[10] = psql.Raw("DEFAULT") + } + + if s.SourceContainer.IsValue() { + vals[11] = psql.Arg(s.SourceContainer.MustGet()) + } else { + vals[11] = psql.Raw("DEFAULT") + } + + if s.SourceDescription.IsValue() { + vals[12] = psql.Arg(s.SourceDescription.MustGet()) + } else { + vals[12] = psql.Raw("DEFAULT") + } + + if s.SourceRoof.IsValue() { + vals[13] = psql.Arg(s.SourceRoof.MustGet()) + } else { + vals[13] = psql.Raw("DEFAULT") + } + + if s.SourceStagnant.IsValue() { + vals[14] = psql.Arg(s.SourceStagnant.MustGet()) + } else { + vals[14] = psql.Raw("DEFAULT") + } + + if s.TimeOfDayDay.IsValue() { + vals[15] = psql.Arg(s.TimeOfDayDay.MustGet()) + } else { + vals[15] = psql.Raw("DEFAULT") + } + + if s.TimeOfDayEarly.IsValue() { + vals[16] = psql.Arg(s.TimeOfDayEarly.MustGet()) + } else { + vals[16] = psql.Raw("DEFAULT") + } + + if s.TimeOfDayEvening.IsValue() { + vals[17] = psql.Arg(s.TimeOfDayEvening.MustGet()) + } else { + vals[17] = psql.Raw("DEFAULT") + } + + if s.TimeOfDayNight.IsValue() { + vals[18] = psql.Arg(s.TimeOfDayNight.MustGet()) + } else { + vals[18] = psql.Raw("DEFAULT") + } + + if s.PublicID.IsValue() { + vals[19] = psql.Arg(s.PublicID.MustGet()) + } else { + vals[19] = psql.Raw("DEFAULT") + } + + if s.ReporterAddress.IsValue() { + vals[20] = psql.Arg(s.ReporterAddress.MustGet()) + } else { + vals[20] = psql.Raw("DEFAULT") + } + + if s.ReporterEmail.IsValue() { + vals[21] = psql.Arg(s.ReporterEmail.MustGet()) + } else { + vals[21] = psql.Raw("DEFAULT") + } + + if s.ReporterName.IsValue() { + vals[22] = psql.Arg(s.ReporterName.MustGet()) + } else { + vals[22] = psql.Raw("DEFAULT") + } + + if s.ReporterPhone.IsValue() { + vals[23] = psql.Arg(s.ReporterPhone.MustGet()) + } else { + vals[23] = psql.Raw("DEFAULT") + } + + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") + })) +} + +func (s PublicreportNuisanceSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { + return um.Set(s.Expressions()...) +} + +func (s PublicreportNuisanceSetter) Expressions(prefix ...string) []bob.Expression { + exprs := make([]bob.Expression, 0, 24) + + if s.ID.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "id")...), + psql.Arg(s.ID), + }}) + } + + if s.AdditionalInfo.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "additional_info")...), + psql.Arg(s.AdditionalInfo), + }}) + } + + if s.Created.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "created")...), + psql.Arg(s.Created), + }}) + } + + if s.Duration.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "duration")...), + psql.Arg(s.Duration), + }}) + } + + if s.Email.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "email")...), + psql.Arg(s.Email), + }}) + } + + if s.InspectionType.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "inspection_type")...), + psql.Arg(s.InspectionType), + }}) + } + + if s.Location.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "location")...), + psql.Arg(s.Location), + }}) + } + + if s.PreferredDateRange.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "preferred_date_range")...), + psql.Arg(s.PreferredDateRange), + }}) + } + + if s.PreferredTime.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "preferred_time")...), + psql.Arg(s.PreferredTime), + }}) + } + + if s.RequestCall.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "request_call")...), + psql.Arg(s.RequestCall), + }}) + } + + if s.Severity.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "severity")...), + psql.Arg(s.Severity), + }}) + } + + if s.SourceContainer.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "source_container")...), + psql.Arg(s.SourceContainer), + }}) + } + + if s.SourceDescription.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "source_description")...), + psql.Arg(s.SourceDescription), + }}) + } + + if s.SourceRoof.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "source_roof")...), + psql.Arg(s.SourceRoof), + }}) + } + + if s.SourceStagnant.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "source_stagnant")...), + psql.Arg(s.SourceStagnant), + }}) + } + + if s.TimeOfDayDay.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "time_of_day_day")...), + psql.Arg(s.TimeOfDayDay), + }}) + } + + if s.TimeOfDayEarly.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "time_of_day_early")...), + psql.Arg(s.TimeOfDayEarly), + }}) + } + + if s.TimeOfDayEvening.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "time_of_day_evening")...), + psql.Arg(s.TimeOfDayEvening), + }}) + } + + if s.TimeOfDayNight.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "time_of_day_night")...), + psql.Arg(s.TimeOfDayNight), + }}) + } + + if s.PublicID.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "public_id")...), + psql.Arg(s.PublicID), + }}) + } + + if s.ReporterAddress.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "reporter_address")...), + psql.Arg(s.ReporterAddress), + }}) + } + + if s.ReporterEmail.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "reporter_email")...), + psql.Arg(s.ReporterEmail), + }}) + } + + if s.ReporterName.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "reporter_name")...), + psql.Arg(s.ReporterName), + }}) + } + + if s.ReporterPhone.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "reporter_phone")...), + psql.Arg(s.ReporterPhone), + }}) + } + + return exprs +} + +// FindPublicreportNuisance retrieves a single record by primary key +// If cols is empty Find will return all columns. +func FindPublicreportNuisance(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*PublicreportNuisance, error) { + if len(cols) == 0 { + return PublicreportNuisances.Query( + sm.Where(PublicreportNuisances.Columns.ID.EQ(psql.Arg(IDPK))), + ).One(ctx, exec) + } + + return PublicreportNuisances.Query( + sm.Where(PublicreportNuisances.Columns.ID.EQ(psql.Arg(IDPK))), + sm.Columns(PublicreportNuisances.Columns.Only(cols...)), + ).One(ctx, exec) +} + +// PublicreportNuisanceExists checks the presence of a single record by primary key +func PublicreportNuisanceExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error) { + return PublicreportNuisances.Query( + sm.Where(PublicreportNuisances.Columns.ID.EQ(psql.Arg(IDPK))), + ).Exists(ctx, exec) +} + +// AfterQueryHook is called after PublicreportNuisance is retrieved from the database +func (o *PublicreportNuisance) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { + var err error + + switch queryType { + case bob.QueryTypeSelect: + ctx, err = PublicreportNuisances.AfterSelectHooks.RunHooks(ctx, exec, PublicreportNuisanceSlice{o}) + case bob.QueryTypeInsert: + ctx, err = PublicreportNuisances.AfterInsertHooks.RunHooks(ctx, exec, PublicreportNuisanceSlice{o}) + case bob.QueryTypeUpdate: + ctx, err = PublicreportNuisances.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportNuisanceSlice{o}) + case bob.QueryTypeDelete: + ctx, err = PublicreportNuisances.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportNuisanceSlice{o}) + } + + return err +} + +// primaryKeyVals returns the primary key values of the PublicreportNuisance +func (o *PublicreportNuisance) primaryKeyVals() bob.Expression { + return psql.Arg(o.ID) +} + +func (o *PublicreportNuisance) pkEQ() dialect.Expression { + return psql.Quote("publicreport.nuisance", "id").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + return o.primaryKeyVals().WriteSQL(ctx, w, d, start) + })) +} + +// Update uses an executor to update the PublicreportNuisance +func (o *PublicreportNuisance) Update(ctx context.Context, exec bob.Executor, s *PublicreportNuisanceSetter) error { + v, err := PublicreportNuisances.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec) + if err != nil { + return err + } + + *o = *v + + return nil +} + +// Delete deletes a single PublicreportNuisance record with an executor +func (o *PublicreportNuisance) Delete(ctx context.Context, exec bob.Executor) error { + _, err := PublicreportNuisances.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec) + return err +} + +// Reload refreshes the PublicreportNuisance using the executor +func (o *PublicreportNuisance) Reload(ctx context.Context, exec bob.Executor) error { + o2, err := PublicreportNuisances.Query( + sm.Where(PublicreportNuisances.Columns.ID.EQ(psql.Arg(o.ID))), + ).One(ctx, exec) + if err != nil { + return err + } + + *o = *o2 + + return nil +} + +// AfterQueryHook is called after PublicreportNuisanceSlice is retrieved from the database +func (o PublicreportNuisanceSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { + var err error + + switch queryType { + case bob.QueryTypeSelect: + ctx, err = PublicreportNuisances.AfterSelectHooks.RunHooks(ctx, exec, o) + case bob.QueryTypeInsert: + ctx, err = PublicreportNuisances.AfterInsertHooks.RunHooks(ctx, exec, o) + case bob.QueryTypeUpdate: + ctx, err = PublicreportNuisances.AfterUpdateHooks.RunHooks(ctx, exec, o) + case bob.QueryTypeDelete: + ctx, err = PublicreportNuisances.AfterDeleteHooks.RunHooks(ctx, exec, o) + } + + return err +} + +func (o PublicreportNuisanceSlice) pkIN() dialect.Expression { + if len(o) == 0 { + return psql.Raw("NULL") + } + + return psql.Quote("publicreport.nuisance", "id").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + pkPairs := make([]bob.Expression, len(o)) + for i, row := range o { + pkPairs[i] = row.primaryKeyVals() + } + return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "") + })) +} + +// copyMatchingRows finds models in the given slice that have the same primary key +// then it first copies the existing relationships from the old model to the new model +// and then replaces the old model in the slice with the new model +func (o PublicreportNuisanceSlice) copyMatchingRows(from ...*PublicreportNuisance) { + for i, old := range o { + for _, new := range from { + if new.ID != old.ID { + continue + } + + o[i] = new + break + } + } +} + +// UpdateMod modifies an update query with "WHERE primary_key IN (o...)" +func (o PublicreportNuisanceSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] { + return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) { + q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { + return PublicreportNuisances.BeforeUpdateHooks.RunHooks(ctx, exec, o) + }) + + q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error { + var err error + switch retrieved := retrieved.(type) { + case *PublicreportNuisance: + o.copyMatchingRows(retrieved) + case []*PublicreportNuisance: + o.copyMatchingRows(retrieved...) + case PublicreportNuisanceSlice: + o.copyMatchingRows(retrieved...) + default: + // If the retrieved value is not a PublicreportNuisance or a slice of PublicreportNuisance + // then run the AfterUpdateHooks on the slice + _, err = PublicreportNuisances.AfterUpdateHooks.RunHooks(ctx, exec, o) + } + + return err + })) + + q.AppendWhere(o.pkIN()) + }) +} + +// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)" +func (o PublicreportNuisanceSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] { + return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) { + q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { + return PublicreportNuisances.BeforeDeleteHooks.RunHooks(ctx, exec, o) + }) + + q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error { + var err error + switch retrieved := retrieved.(type) { + case *PublicreportNuisance: + o.copyMatchingRows(retrieved) + case []*PublicreportNuisance: + o.copyMatchingRows(retrieved...) + case PublicreportNuisanceSlice: + o.copyMatchingRows(retrieved...) + default: + // If the retrieved value is not a PublicreportNuisance or a slice of PublicreportNuisance + // then run the AfterDeleteHooks on the slice + _, err = PublicreportNuisances.AfterDeleteHooks.RunHooks(ctx, exec, o) + } + + return err + })) + + q.AppendWhere(o.pkIN()) + }) +} + +func (o PublicreportNuisanceSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportNuisanceSetter) error { + if len(o) == 0 { + return nil + } + + _, err := PublicreportNuisances.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec) + return err +} + +func (o PublicreportNuisanceSlice) DeleteAll(ctx context.Context, exec bob.Executor) error { + if len(o) == 0 { + return nil + } + + _, err := PublicreportNuisances.Delete(o.DeleteMod()).Exec(ctx, exec) + return err +} + +func (o PublicreportNuisanceSlice) ReloadAll(ctx context.Context, exec bob.Executor) error { + if len(o) == 0 { + return nil + } + + o2, err := PublicreportNuisances.Query(sm.Where(o.pkIN())).All(ctx, exec) + if err != nil { + return err + } + + o.copyMatchingRows(o2...) + + return nil +} + +type publicreportNuisanceWhere[Q psql.Filterable] struct { + ID psql.WhereMod[Q, int32] + AdditionalInfo psql.WhereMod[Q, string] + Created psql.WhereMod[Q, time.Time] + Duration psql.WhereMod[Q, enums.PublicreportNuisancedurationtype] + Email psql.WhereMod[Q, string] + InspectionType psql.WhereMod[Q, enums.PublicreportNuisanceinspectiontype] + Location psql.WhereMod[Q, enums.PublicreportNuisancelocationtype] + PreferredDateRange psql.WhereMod[Q, enums.PublicreportNuisancepreferreddaterangetype] + PreferredTime psql.WhereMod[Q, enums.PublicreportNuisancepreferredtimetype] + RequestCall psql.WhereMod[Q, bool] + Severity psql.WhereMod[Q, int16] + SourceContainer psql.WhereMod[Q, bool] + SourceDescription psql.WhereMod[Q, string] + SourceRoof psql.WhereMod[Q, bool] + SourceStagnant psql.WhereMod[Q, bool] + TimeOfDayDay psql.WhereMod[Q, bool] + TimeOfDayEarly psql.WhereMod[Q, bool] + TimeOfDayEvening psql.WhereMod[Q, bool] + TimeOfDayNight psql.WhereMod[Q, bool] + PublicID psql.WhereMod[Q, string] + ReporterAddress psql.WhereMod[Q, string] + ReporterEmail psql.WhereMod[Q, string] + ReporterName psql.WhereMod[Q, string] + ReporterPhone psql.WhereMod[Q, string] +} + +func (publicreportNuisanceWhere[Q]) AliasedAs(alias string) publicreportNuisanceWhere[Q] { + return buildPublicreportNuisanceWhere[Q](buildPublicreportNuisanceColumns(alias)) +} + +func buildPublicreportNuisanceWhere[Q psql.Filterable](cols publicreportNuisanceColumns) publicreportNuisanceWhere[Q] { + return publicreportNuisanceWhere[Q]{ + ID: psql.Where[Q, int32](cols.ID), + AdditionalInfo: psql.Where[Q, string](cols.AdditionalInfo), + Created: psql.Where[Q, time.Time](cols.Created), + Duration: psql.Where[Q, enums.PublicreportNuisancedurationtype](cols.Duration), + Email: psql.Where[Q, string](cols.Email), + InspectionType: psql.Where[Q, enums.PublicreportNuisanceinspectiontype](cols.InspectionType), + Location: psql.Where[Q, enums.PublicreportNuisancelocationtype](cols.Location), + PreferredDateRange: psql.Where[Q, enums.PublicreportNuisancepreferreddaterangetype](cols.PreferredDateRange), + PreferredTime: psql.Where[Q, enums.PublicreportNuisancepreferredtimetype](cols.PreferredTime), + RequestCall: psql.Where[Q, bool](cols.RequestCall), + Severity: psql.Where[Q, int16](cols.Severity), + SourceContainer: psql.Where[Q, bool](cols.SourceContainer), + SourceDescription: psql.Where[Q, string](cols.SourceDescription), + SourceRoof: psql.Where[Q, bool](cols.SourceRoof), + SourceStagnant: psql.Where[Q, bool](cols.SourceStagnant), + TimeOfDayDay: psql.Where[Q, bool](cols.TimeOfDayDay), + TimeOfDayEarly: psql.Where[Q, bool](cols.TimeOfDayEarly), + TimeOfDayEvening: psql.Where[Q, bool](cols.TimeOfDayEvening), + TimeOfDayNight: psql.Where[Q, bool](cols.TimeOfDayNight), + PublicID: psql.Where[Q, string](cols.PublicID), + ReporterAddress: psql.Where[Q, string](cols.ReporterAddress), + ReporterEmail: psql.Where[Q, string](cols.ReporterEmail), + ReporterName: psql.Where[Q, string](cols.ReporterName), + ReporterPhone: psql.Where[Q, string](cols.ReporterPhone), + } +} diff --git a/public-report/endpoint.go b/public-report/endpoint.go index bb872b00..a32a0c26 100644 --- a/public-report/endpoint.go +++ b/public-report/endpoint.go @@ -9,6 +9,7 @@ import ( "time" "github.com/Gleipnir-Technology/nidus-sync/db" + "github.com/Gleipnir-Technology/nidus-sync/db/enums" "github.com/Gleipnir-Technology/nidus-sync/db/models" "github.com/Gleipnir-Technology/nidus-sync/h3utils" "github.com/Gleipnir-Technology/nidus-sync/htmlpage" @@ -26,6 +27,8 @@ func Router() chi.Router { r := chi.NewRouter() r.Get("/", getRoot) r.Get("/nuisance", getNuisance) + r.Post("/nuisance-submit", postNuisance) + r.Get("/nuisance-submit-complete", getNuisanceSubmitComplete) r.Get("/pool", getPool) r.Get("/quick", getQuick) r.Post("/quick-submit", postQuick) @@ -53,6 +56,16 @@ func getNuisance(w http.ResponseWriter, r *http.Request) { ContextNuisance{}, ) } +func getNuisanceSubmitComplete(w http.ResponseWriter, r *http.Request) { + report := r.URL.Query().Get("report") + htmlpage.RenderOrError( + w, + NuisanceSubmitComplete, + ContextNuisanceSubmitComplete{ + ReportID: report, + }, + ) +} func getPool(w http.ResponseWriter, r *http.Request) { htmlpage.RenderOrError( w, @@ -94,6 +107,117 @@ func getStatus(w http.ResponseWriter, r *http.Request) { ContextStatus{}, ) } +func postNuisance(w http.ResponseWriter, r *http.Request) { + err := r.ParseForm() + if err != nil { + respondError(w, "Failed to parse form", err, http.StatusBadRequest) + return + } + tod_early := boolFromForm(r, "tod-early") + tod_day := boolFromForm(r, "tod-day") + tod_evening := boolFromForm(r, "tod-evening") + tod_night := boolFromForm(r, "tod-night") + + source_stagnant := boolFromForm(r, "source-stagnant") + source_container := boolFromForm(r, "source-container") + source_roof := boolFromForm(r, "source-container") + + request_call := boolFromForm(r, "request-call") + + duration_str := postFormValueOrNone(r, "duration") + var duration enums.PublicreportNuisancedurationtype + err = duration.Scan(duration_str) + if err != nil { + respondError(w, fmt.Sprintf("Failed to interpret 'duration' of '%s'", duration_str), err, http.StatusBadRequest) + return + } + + + inspection_type_str := postFormValueOrNone(r, "inspection-type") + var inspection_type enums.PublicreportNuisanceinspectiontype + err = inspection_type.Scan(inspection_type_str) + if err != nil { + respondError(w, fmt.Sprintf("Failed to interpret 'inspection-type' of '%s'", inspection_type_str), err, http.StatusBadRequest) + return + } + + location_str := postFormValueOrNone(r, "location") + var location enums.PublicreportNuisancelocationtype + err = location.Scan(location_str) + if err != nil { + respondError(w, fmt.Sprintf("Failed to interpret 'location' of '%s'", location_str), err, http.StatusBadRequest) + return + } + preferred_date_range_str := postFormValueOrNone(r, "preferred-date-range") + var preferred_date_range enums.PublicreportNuisancepreferreddaterangetype + err = preferred_date_range.Scan(preferred_date_range_str) + if err != nil { + respondError(w, fmt.Sprintf("Failed to interpret 'preferred-date-range' of '%s'", preferred_date_range_str), err, http.StatusBadRequest) + return + } + preferred_time_str := postFormValueOrNone(r, "preferred-time") + var preferred_time enums.PublicreportNuisancepreferredtimetype + err = preferred_time.Scan(preferred_time_str) + if err != nil { + respondError(w, fmt.Sprintf("Failed to interpret 'preferred-time' of '%s'", preferred_time_str), err, http.StatusBadRequest) + return + } + + severity_str := r.PostFormValue("severity") + severity, err := strconv.ParseInt(severity_str, 10, 16) + if err != nil { + respondError(w, fmt.Sprintf("Failed to interpret 'severity' of '%s' as an integer", severity_str), err, http.StatusBadRequest) + return + } + + source_description := r.PostFormValue("source-description") + address := r.PostFormValue("address") + name := r.PostFormValue("name") + phone := r.PostFormValue("phone") + email := r.PostFormValue("email") + additional_info := r.PostFormValue("additional-info") + + public_id, err := GenerateReportID() + if err != nil { + respondError(w, "Failed to create quick report public ID", err, http.StatusInternalServerError) + return + } + + log.Info().Str("address", address).Str("name", name).Msg("Got report") + setter := models.PublicreportNuisanceSetter{ + AdditionalInfo: omit.From(additional_info), + Created: omit.From(time.Now()), + Duration: omit.From(duration), + Email: omit.From(email), + InspectionType: omit.From(inspection_type), + Location: omit.From(location), + PreferredDateRange: omit.From(preferred_date_range), + PreferredTime: omit.From(preferred_time), + PublicID: omit.From(public_id), + RequestCall: omit.From(request_call), + Severity: omit.From(int16(severity)), + SourceContainer: omit.From(source_container), + SourceDescription: omit.From(source_description), + SourceRoof: omit.From(source_roof), + SourceStagnant: omit.From(source_stagnant), + TimeOfDayDay: omit.From(tod_day), + TimeOfDayEarly: omit.From(tod_early), + TimeOfDayEvening: omit.From(tod_evening), + TimeOfDayNight: omit.From(tod_night), + ReporterAddress: omit.From(address), + ReporterEmail: omit.From(email), + ReporterName: omit.From(name), + ReporterPhone: omit.From(phone), + } + nuisance, err := models.PublicreportNuisances.Insert(&setter).One(r.Context(), db.PGInstance.BobDB) + if err != nil { + respondError(w, "Failed to create database record", err, http.StatusInternalServerError) + return + } + log.Info().Str("public_id", public_id).Int32("id", nuisance.ID).Msg("Created nuisance report") + http.Redirect(w, r, fmt.Sprintf("/nuisance-submit-complete?report=%s", public_id), http.StatusFound) +} + func postQuick(w http.ResponseWriter, r *http.Request) { err := r.ParseMultipartForm(32 << 10) // 32 MB buffer if err != nil { @@ -237,3 +361,19 @@ func respondError(w http.ResponseWriter, m string, e error, s int) { log.Warn().Int("status", s).Err(e).Str("user message", m).Msg("Responding with an error") http.Error(w, m, s) } + +func boolFromForm(r *http.Request, k string) bool { + s := r.PostFormValue(k) + if s == "on" { + return true + } + return false +} + +func postFormValueOrNone(r *http.Request, k string) string { + v := r.PostFormValue(k) + if v == "" { + return "none" + } + return v +} diff --git a/public-report/page.go b/public-report/page.go index e44c7489..a0b6e06a 100644 --- a/public-report/page.go +++ b/public-report/page.go @@ -14,6 +14,9 @@ var embeddedFiles embed.FS var EmbeddedStaticFS embed.FS type ContextNuisance struct{} +type ContextNuisanceSubmitComplete struct { + ReportID string +} type ContextPool struct{} type ContextQuick struct{} type ContextQuickSubmitComplete struct { @@ -27,6 +30,7 @@ type ContextStatus struct{} var ( Nuisance = buildTemplate("nuisance", "base") + NuisanceSubmitComplete = buildTemplate("nuisance-submit-complete", "base") Pool = buildTemplate("pool", "base") Quick = buildTemplate("quick", "base") QuickSubmitComplete = buildTemplate("quick-submit-complete", "base") diff --git a/public-report/template/nuisance-submit-complete.html b/public-report/template/nuisance-submit-complete.html new file mode 100644 index 00000000..6cf6efcf --- /dev/null +++ b/public-report/template/nuisance-submit-complete.html @@ -0,0 +1,115 @@ +{{template "base.html" .}} + +{{define "title"}}Nuisance Submission Complete{{end}} +{{define "extraheader"}} + + +{{end}} +{{define "content"}} +
Your report has been successfully submitted.
+If you need to update your contact information or have questions about your report, please contact our Mosquito Control Unit at (123) 456-7890 or mosquito@example.gov and reference your Report ID.
+