Prune data layer on nuisance report
After this, we can successfully POST the report.
This commit is contained in:
parent
1fbe41b725
commit
bf8c4ca6da
8 changed files with 209 additions and 175 deletions
|
|
@ -96,39 +96,30 @@ var PublicreportNuisances = Table[
|
|||
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: "",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ReporterName: column{
|
||||
Name: "reporter_name",
|
||||
DBType: "text",
|
||||
Default: "",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ReporterPhone: column{
|
||||
Name: "reporter_phone",
|
||||
DBType: "text",
|
||||
Default: "",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
|
|
@ -251,7 +242,6 @@ type publicreportNuisanceColumns struct {
|
|||
SourceDescription column
|
||||
SourceStagnant column
|
||||
PublicID column
|
||||
ReporterAddress column
|
||||
ReporterEmail column
|
||||
ReporterName column
|
||||
ReporterPhone column
|
||||
|
|
@ -264,7 +254,7 @@ type publicreportNuisanceColumns struct {
|
|||
|
||||
func (c publicreportNuisanceColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ID, c.AdditionalInfo, c.Created, c.Duration, c.SourceLocation, c.SourceContainer, c.SourceDescription, c.SourceStagnant, c.PublicID, c.ReporterAddress, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Address, c.Location, c.Status, c.OrganizationID, c.SourceGutter,
|
||||
c.ID, c.AdditionalInfo, c.Created, c.Duration, c.SourceLocation, c.SourceContainer, c.SourceDescription, c.SourceStagnant, c.PublicID, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Address, c.Location, c.Status, c.OrganizationID, c.SourceGutter,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2855,10 +2855,9 @@ func (f *Factory) FromExistingPublicreportNuisance(m *models.PublicreportNuisanc
|
|||
o.SourceDescription = func() string { return m.SourceDescription }
|
||||
o.SourceStagnant = func() bool { return m.SourceStagnant }
|
||||
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 }
|
||||
o.ReporterEmail = func() null.Val[string] { return m.ReporterEmail }
|
||||
o.ReporterName = func() null.Val[string] { return m.ReporterName }
|
||||
o.ReporterPhone = func() null.Val[string] { return m.ReporterPhone }
|
||||
o.Address = func() string { return m.Address }
|
||||
o.Location = func() null.Val[string] { return m.Location }
|
||||
o.Status = func() enums.PublicreportReportstatustype { return m.Status }
|
||||
|
|
|
|||
|
|
@ -47,10 +47,9 @@ type PublicreportNuisanceTemplate struct {
|
|||
SourceDescription func() string
|
||||
SourceStagnant func() bool
|
||||
PublicID func() string
|
||||
ReporterAddress func() string
|
||||
ReporterEmail func() string
|
||||
ReporterName func() string
|
||||
ReporterPhone func() string
|
||||
ReporterEmail func() null.Val[string]
|
||||
ReporterName func() null.Val[string]
|
||||
ReporterPhone func() null.Val[string]
|
||||
Address func() string
|
||||
Location func() null.Val[string]
|
||||
Status func() enums.PublicreportReportstatustype
|
||||
|
|
@ -130,21 +129,17 @@ func (o PublicreportNuisanceTemplate) BuildSetter() *models.PublicreportNuisance
|
|||
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)
|
||||
m.ReporterEmail = omitnull.FromNull(val)
|
||||
}
|
||||
if o.ReporterName != nil {
|
||||
val := o.ReporterName()
|
||||
m.ReporterName = omit.From(val)
|
||||
m.ReporterName = omitnull.FromNull(val)
|
||||
}
|
||||
if o.ReporterPhone != nil {
|
||||
val := o.ReporterPhone()
|
||||
m.ReporterPhone = omit.From(val)
|
||||
m.ReporterPhone = omitnull.FromNull(val)
|
||||
}
|
||||
if o.Address != nil {
|
||||
val := o.Address()
|
||||
|
|
@ -215,9 +210,6 @@ func (o PublicreportNuisanceTemplate) Build() *models.PublicreportNuisance {
|
|||
if o.PublicID != nil {
|
||||
m.PublicID = o.PublicID()
|
||||
}
|
||||
if o.ReporterAddress != nil {
|
||||
m.ReporterAddress = o.ReporterAddress()
|
||||
}
|
||||
if o.ReporterEmail != nil {
|
||||
m.ReporterEmail = o.ReporterEmail()
|
||||
}
|
||||
|
|
@ -294,22 +286,6 @@ func ensureCreatablePublicreportNuisance(m *models.PublicreportNuisanceSetter) {
|
|||
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)
|
||||
}
|
||||
if !(m.Address.IsValue()) {
|
||||
val := random_string(nil)
|
||||
m.Address = omit.From(val)
|
||||
|
|
@ -450,7 +426,6 @@ func (m publicreportNuisanceMods) RandomizeAllColumns(f *faker.Faker) Publicrepo
|
|||
PublicreportNuisanceMods.RandomSourceDescription(f),
|
||||
PublicreportNuisanceMods.RandomSourceStagnant(f),
|
||||
PublicreportNuisanceMods.RandomPublicID(f),
|
||||
PublicreportNuisanceMods.RandomReporterAddress(f),
|
||||
PublicreportNuisanceMods.RandomReporterEmail(f),
|
||||
PublicreportNuisanceMods.RandomReporterName(f),
|
||||
PublicreportNuisanceMods.RandomReporterPhone(f),
|
||||
|
|
@ -742,45 +717,14 @@ func (m publicreportNuisanceMods) RandomPublicID(f *faker.Faker) PublicreportNui
|
|||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportNuisanceMods) ReporterAddress(val string) PublicreportNuisanceMod {
|
||||
func (m publicreportNuisanceMods) ReporterEmail(val null.Val[string]) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterAddress = func() string { return val }
|
||||
o.ReporterEmail = func() null.Val[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 {
|
||||
func (m publicreportNuisanceMods) ReporterEmailFunc(f func() null.Val[string]) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterEmail = f
|
||||
})
|
||||
|
|
@ -795,23 +739,45 @@ func (m publicreportNuisanceMods) UnsetReporterEmail() PublicreportNuisanceMod {
|
|||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportNuisanceMods) RandomReporterEmail(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterEmail = func() string {
|
||||
return random_string(f)
|
||||
o.ReporterEmail = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportNuisanceMods) RandomReporterEmailNotNull(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterEmail = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportNuisanceMods) ReporterName(val string) PublicreportNuisanceMod {
|
||||
func (m publicreportNuisanceMods) ReporterName(val null.Val[string]) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterName = func() string { return val }
|
||||
o.ReporterName = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportNuisanceMods) ReporterNameFunc(f func() string) PublicreportNuisanceMod {
|
||||
func (m publicreportNuisanceMods) ReporterNameFunc(f func() null.Val[string]) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterName = f
|
||||
})
|
||||
|
|
@ -826,23 +792,45 @@ func (m publicreportNuisanceMods) UnsetReporterName() PublicreportNuisanceMod {
|
|||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportNuisanceMods) RandomReporterName(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterName = func() string {
|
||||
return random_string(f)
|
||||
o.ReporterName = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportNuisanceMods) RandomReporterNameNotNull(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterName = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportNuisanceMods) ReporterPhone(val string) PublicreportNuisanceMod {
|
||||
func (m publicreportNuisanceMods) ReporterPhone(val null.Val[string]) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterPhone = func() string { return val }
|
||||
o.ReporterPhone = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportNuisanceMods) ReporterPhoneFunc(f func() string) PublicreportNuisanceMod {
|
||||
func (m publicreportNuisanceMods) ReporterPhoneFunc(f func() null.Val[string]) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterPhone = f
|
||||
})
|
||||
|
|
@ -857,10 +845,32 @@ func (m publicreportNuisanceMods) UnsetReporterPhone() PublicreportNuisanceMod {
|
|||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportNuisanceMods) RandomReporterPhone(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterPhone = func() string {
|
||||
return random_string(f)
|
||||
o.ReporterPhone = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportNuisanceMods) RandomReporterPhoneNotNull(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.ReporterPhone = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
60
db/migrations/00047_public_nuisance_pruning.sql
Normal file
60
db/migrations/00047_public_nuisance_pruning.sql
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
-- +goose Up
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN email;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN inspection_type;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN preferred_date_range;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN preferred_time;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN request_call;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN severity;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN source_roof;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN time_of_day_day;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN time_of_day_early;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN time_of_day_evening;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN time_of_day_night;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN source_gutter BOOLEAN;
|
||||
UPDATE publicreport.nuisance SET source_gutter = FALSE;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN source_gutter SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN reporter_address;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN reporter_email DROP NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN reporter_name DROP NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN reporter_phone DROP NOT NULL;
|
||||
-- +goose Down
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN reporter_phone SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN reporter_name SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN reporter_email SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN reporter_address TEXT;
|
||||
UPDATE publicreport.nuisance SET reporter_address = '';
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN reporter_address SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN source_gutter;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN time_of_day_day BOOLEAN;
|
||||
UPDATE publicreport.nuisance SET time_of_day_day = FALSE;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN time_of_day_day SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN time_of_day_early BOOLEAN;
|
||||
UPDATE publicreport.nuisance SET time_of_day_early = FALSE;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN time_of_day_early SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN time_of_day_evening BOOLEAN;
|
||||
UPDATE publicreport.nuisance SET time_of_day_evening = FALSE;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN time_of_day_evening SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN time_of_day_night BOOLEAN;
|
||||
UPDATE publicreport.nuisance SET time_of_day_night = FALSE;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN time_of_day_night SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN source_roof BOOLEAN;
|
||||
UPDATE publicreport.nuisance SET source_roof = FALSE;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN source_roof SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN severity SMALLINT;
|
||||
UPDATE publicreport.nuisance SET severity = 0;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN severity SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN request_call BOOLEAN;
|
||||
UPDATE publicreport.nuisance SET request_call = FALSE;
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN request_call SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN preferred_time publicreport.NuisancePreferredTimeType;
|
||||
UPDATE publicreport.nuisance SET preferred_time = 'none';
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN preferred_time SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN preferred_date_range publicreport.NuisancePreferredDateRangeType;
|
||||
UPDATE publicreport.nuisance SET preferred_date_range = 'none';
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN preferred_date_range SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN inspection_type publicreport.NuisanceInspectionType;
|
||||
UPDATE publicreport.nuisance SET inspection_type = 'neighborhood';
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN inspection_type SET NOT NULL;
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN email TEXT;
|
||||
UPDATE publicreport.nuisance SET email = '';
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN email SET NOT NULL;
|
||||
|
|
@ -36,10 +36,9 @@ type PublicreportNuisance struct {
|
|||
SourceDescription string `db:"source_description" `
|
||||
SourceStagnant bool `db:"source_stagnant" `
|
||||
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" `
|
||||
ReporterEmail null.Val[string] `db:"reporter_email" `
|
||||
ReporterName null.Val[string] `db:"reporter_name" `
|
||||
ReporterPhone null.Val[string] `db:"reporter_phone" `
|
||||
Address string `db:"address" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
Status enums.PublicreportReportstatustype `db:"status" `
|
||||
|
|
@ -67,7 +66,7 @@ type publicreportNuisanceR struct {
|
|||
func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns {
|
||||
return publicreportNuisanceColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"id", "additional_info", "created", "duration", "source_location", "source_container", "source_description", "source_stagnant", "public_id", "reporter_address", "reporter_email", "reporter_name", "reporter_phone", "address", "location", "status", "organization_id", "source_gutter",
|
||||
"id", "additional_info", "created", "duration", "source_location", "source_container", "source_description", "source_stagnant", "public_id", "reporter_email", "reporter_name", "reporter_phone", "address", "location", "status", "organization_id", "source_gutter",
|
||||
).WithParent("publicreport.nuisance"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
|
|
@ -79,7 +78,6 @@ func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns
|
|||
SourceDescription: psql.Quote(alias, "source_description"),
|
||||
SourceStagnant: psql.Quote(alias, "source_stagnant"),
|
||||
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"),
|
||||
|
|
@ -103,7 +101,6 @@ type publicreportNuisanceColumns struct {
|
|||
SourceDescription psql.Expression
|
||||
SourceStagnant psql.Expression
|
||||
PublicID psql.Expression
|
||||
ReporterAddress psql.Expression
|
||||
ReporterEmail psql.Expression
|
||||
ReporterName psql.Expression
|
||||
ReporterPhone psql.Expression
|
||||
|
|
@ -135,10 +132,9 @@ type PublicreportNuisanceSetter struct {
|
|||
SourceDescription omit.Val[string] `db:"source_description" `
|
||||
SourceStagnant omit.Val[bool] `db:"source_stagnant" `
|
||||
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" `
|
||||
ReporterEmail omitnull.Val[string] `db:"reporter_email" `
|
||||
ReporterName omitnull.Val[string] `db:"reporter_name" `
|
||||
ReporterPhone omitnull.Val[string] `db:"reporter_phone" `
|
||||
Address omit.Val[string] `db:"address" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
Status omit.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
|
|
@ -147,7 +143,7 @@ type PublicreportNuisanceSetter struct {
|
|||
}
|
||||
|
||||
func (s PublicreportNuisanceSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 18)
|
||||
vals := make([]string, 0, 17)
|
||||
if s.ID.IsValue() {
|
||||
vals = append(vals, "id")
|
||||
}
|
||||
|
|
@ -175,16 +171,13 @@ func (s PublicreportNuisanceSetter) SetColumns() []string {
|
|||
if s.PublicID.IsValue() {
|
||||
vals = append(vals, "public_id")
|
||||
}
|
||||
if s.ReporterAddress.IsValue() {
|
||||
vals = append(vals, "reporter_address")
|
||||
}
|
||||
if s.ReporterEmail.IsValue() {
|
||||
if !s.ReporterEmail.IsUnset() {
|
||||
vals = append(vals, "reporter_email")
|
||||
}
|
||||
if s.ReporterName.IsValue() {
|
||||
if !s.ReporterName.IsUnset() {
|
||||
vals = append(vals, "reporter_name")
|
||||
}
|
||||
if s.ReporterPhone.IsValue() {
|
||||
if !s.ReporterPhone.IsUnset() {
|
||||
vals = append(vals, "reporter_phone")
|
||||
}
|
||||
if s.Address.IsValue() {
|
||||
|
|
@ -233,17 +226,14 @@ func (s PublicreportNuisanceSetter) Overwrite(t *PublicreportNuisance) {
|
|||
if s.PublicID.IsValue() {
|
||||
t.PublicID = s.PublicID.MustGet()
|
||||
}
|
||||
if s.ReporterAddress.IsValue() {
|
||||
t.ReporterAddress = s.ReporterAddress.MustGet()
|
||||
if !s.ReporterEmail.IsUnset() {
|
||||
t.ReporterEmail = s.ReporterEmail.MustGetNull()
|
||||
}
|
||||
if s.ReporterEmail.IsValue() {
|
||||
t.ReporterEmail = s.ReporterEmail.MustGet()
|
||||
if !s.ReporterName.IsUnset() {
|
||||
t.ReporterName = s.ReporterName.MustGetNull()
|
||||
}
|
||||
if s.ReporterName.IsValue() {
|
||||
t.ReporterName = s.ReporterName.MustGet()
|
||||
}
|
||||
if s.ReporterPhone.IsValue() {
|
||||
t.ReporterPhone = s.ReporterPhone.MustGet()
|
||||
if !s.ReporterPhone.IsUnset() {
|
||||
t.ReporterPhone = s.ReporterPhone.MustGetNull()
|
||||
}
|
||||
if s.Address.IsValue() {
|
||||
t.Address = s.Address.MustGet()
|
||||
|
|
@ -268,7 +258,7 @@ func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) {
|
|||
})
|
||||
|
||||
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
vals := make([]bob.Expression, 18)
|
||||
vals := make([]bob.Expression, 17)
|
||||
if s.ID.IsValue() {
|
||||
vals[0] = psql.Arg(s.ID.MustGet())
|
||||
} else {
|
||||
|
|
@ -323,60 +313,54 @@ func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[8] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.ReporterAddress.IsValue() {
|
||||
vals[9] = psql.Arg(s.ReporterAddress.MustGet())
|
||||
if !s.ReporterEmail.IsUnset() {
|
||||
vals[9] = psql.Arg(s.ReporterEmail.MustGetNull())
|
||||
} else {
|
||||
vals[9] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.ReporterEmail.IsValue() {
|
||||
vals[10] = psql.Arg(s.ReporterEmail.MustGet())
|
||||
if !s.ReporterName.IsUnset() {
|
||||
vals[10] = psql.Arg(s.ReporterName.MustGetNull())
|
||||
} else {
|
||||
vals[10] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.ReporterName.IsValue() {
|
||||
vals[11] = psql.Arg(s.ReporterName.MustGet())
|
||||
if !s.ReporterPhone.IsUnset() {
|
||||
vals[11] = psql.Arg(s.ReporterPhone.MustGetNull())
|
||||
} else {
|
||||
vals[11] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.ReporterPhone.IsValue() {
|
||||
vals[12] = psql.Arg(s.ReporterPhone.MustGet())
|
||||
if s.Address.IsValue() {
|
||||
vals[12] = psql.Arg(s.Address.MustGet())
|
||||
} else {
|
||||
vals[12] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Address.IsValue() {
|
||||
vals[13] = psql.Arg(s.Address.MustGet())
|
||||
if !s.Location.IsUnset() {
|
||||
vals[13] = psql.Arg(s.Location.MustGetNull())
|
||||
} else {
|
||||
vals[13] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Location.IsUnset() {
|
||||
vals[14] = psql.Arg(s.Location.MustGetNull())
|
||||
if s.Status.IsValue() {
|
||||
vals[14] = psql.Arg(s.Status.MustGet())
|
||||
} else {
|
||||
vals[14] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Status.IsValue() {
|
||||
vals[15] = psql.Arg(s.Status.MustGet())
|
||||
if !s.OrganizationID.IsUnset() {
|
||||
vals[15] = psql.Arg(s.OrganizationID.MustGetNull())
|
||||
} else {
|
||||
vals[15] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.OrganizationID.IsUnset() {
|
||||
vals[16] = psql.Arg(s.OrganizationID.MustGetNull())
|
||||
if s.SourceGutter.IsValue() {
|
||||
vals[16] = psql.Arg(s.SourceGutter.MustGet())
|
||||
} else {
|
||||
vals[16] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.SourceGutter.IsValue() {
|
||||
vals[17] = psql.Arg(s.SourceGutter.MustGet())
|
||||
} else {
|
||||
vals[17] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
|
@ -386,7 +370,7 @@ func (s PublicreportNuisanceSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|||
}
|
||||
|
||||
func (s PublicreportNuisanceSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 18)
|
||||
exprs := make([]bob.Expression, 0, 17)
|
||||
|
||||
if s.ID.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
|
|
@ -451,28 +435,21 @@ func (s PublicreportNuisanceSetter) Expressions(prefix ...string) []bob.Expressi
|
|||
}})
|
||||
}
|
||||
|
||||
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() {
|
||||
if !s.ReporterEmail.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "reporter_email")...),
|
||||
psql.Arg(s.ReporterEmail),
|
||||
}})
|
||||
}
|
||||
|
||||
if s.ReporterName.IsValue() {
|
||||
if !s.ReporterName.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "reporter_name")...),
|
||||
psql.Arg(s.ReporterName),
|
||||
}})
|
||||
}
|
||||
|
||||
if s.ReporterPhone.IsValue() {
|
||||
if !s.ReporterPhone.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "reporter_phone")...),
|
||||
psql.Arg(s.ReporterPhone),
|
||||
|
|
@ -822,10 +799,9 @@ type publicreportNuisanceWhere[Q psql.Filterable] struct {
|
|||
SourceDescription psql.WhereMod[Q, string]
|
||||
SourceStagnant 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]
|
||||
ReporterEmail psql.WhereNullMod[Q, string]
|
||||
ReporterName psql.WhereNullMod[Q, string]
|
||||
ReporterPhone psql.WhereNullMod[Q, string]
|
||||
Address psql.WhereMod[Q, string]
|
||||
Location psql.WhereNullMod[Q, string]
|
||||
Status psql.WhereMod[Q, enums.PublicreportReportstatustype]
|
||||
|
|
@ -848,10 +824,9 @@ func buildPublicreportNuisanceWhere[Q psql.Filterable](cols publicreportNuisance
|
|||
SourceDescription: psql.Where[Q, string](cols.SourceDescription),
|
||||
SourceStagnant: psql.Where[Q, bool](cols.SourceStagnant),
|
||||
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),
|
||||
ReporterEmail: psql.WhereNull[Q, string](cols.ReporterEmail),
|
||||
ReporterName: psql.WhereNull[Q, string](cols.ReporterName),
|
||||
ReporterPhone: psql.WhereNull[Q, string](cols.ReporterPhone),
|
||||
Address: psql.Where[Q, string](cols.Address),
|
||||
Location: psql.WhereNull[Q, string](cols.Location),
|
||||
Status: psql.Where[Q, enums.PublicreportReportstatustype](cols.Status),
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ func postNuisance(w http.ResponseWriter, r *http.Request) {
|
|||
respondError(w, "Failed to parse form", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
address := r.PostFormValue("address")
|
||||
source_stagnant := boolFromForm(r, "source-stagnant")
|
||||
source_container := boolFromForm(r, "source-container")
|
||||
source_gutters := boolFromForm(r, "source-gutters")
|
||||
|
|
@ -87,6 +88,7 @@ func postNuisance(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
setter := models.PublicreportNuisanceSetter{
|
||||
AdditionalInfo: omit.From(additional_info),
|
||||
Address: omit.From(address),
|
||||
Created: omit.From(time.Now()),
|
||||
Duration: omit.From(duration),
|
||||
Location: omitnull.FromPtr[string](nil),
|
||||
|
|
@ -97,10 +99,9 @@ func postNuisance(w http.ResponseWriter, r *http.Request) {
|
|||
SourceLocation: omit.From(source_location),
|
||||
SourceStagnant: omit.From(source_stagnant),
|
||||
Status: omit.From(enums.PublicreportReportstatustypeReported),
|
||||
ReporterAddress: omit.FromPtr[string](nil),
|
||||
ReporterEmail: omit.FromPtr[string](nil),
|
||||
ReporterName: omit.FromPtr[string](nil),
|
||||
ReporterPhone: omit.FromPtr[string](nil),
|
||||
ReporterEmail: omitnull.FromPtr[string](nil),
|
||||
ReporterName: omitnull.FromPtr[string](nil),
|
||||
ReporterPhone: omitnull.FromPtr[string](nil),
|
||||
}
|
||||
nuisance, err := models.PublicreportNuisances.Insert(&setter).One(r.Context(), db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -136,9 +136,9 @@ func contentFromNuisance(ctx context.Context, report_id string) (result ContentS
|
|||
result.Report.ID = report_id
|
||||
result.Report.Address = nuisance.Address
|
||||
result.Report.Created = nuisance.Created
|
||||
result.Report.Reporter.Email = nuisance.ReporterEmail
|
||||
result.Report.Reporter.Name = nuisance.ReporterName
|
||||
result.Report.Reporter.Phone = nuisance.ReporterPhone
|
||||
result.Report.Reporter.Email = nuisance.ReporterEmail.GetOr("")
|
||||
result.Report.Reporter.Name = nuisance.ReporterName.GetOr("")
|
||||
result.Report.Reporter.Phone = nuisance.ReporterPhone.GetOr("")
|
||||
|
||||
type LocationGeoJSON struct {
|
||||
Location string
|
||||
|
|
|
|||
|
|
@ -251,7 +251,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
<div class="col-md-12">
|
||||
<label for="source-location" class="form-label">Where on your property do you notice the most mosquito activity?</label>
|
||||
<select class="form-select tall" multiple="true" name="source-location">
|
||||
<option value="">Please select</option>
|
||||
<option value="front-yard">Front yard</option>
|
||||
<option value="backyard">Back yard</option>
|
||||
<option value="garden">Garden</option>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue