Add address number to public reports
This commit is contained in:
parent
1e80c62701
commit
cfe399e44f
10 changed files with 125 additions and 26 deletions
|
|
@ -330,6 +330,15 @@ var PublicreportNuisances = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
AddressNumber: column{
|
||||
Name: "address_number",
|
||||
DBType: "text",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: publicreportNuisanceIndexes{
|
||||
NuisancePkey: index{
|
||||
|
|
@ -430,11 +439,12 @@ type publicreportNuisanceColumns struct {
|
|||
LatlngAccuracyValue column
|
||||
ReporterContactConsent column
|
||||
Location column
|
||||
AddressNumber column
|
||||
}
|
||||
|
||||
func (c publicreportNuisanceColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ID, c.AdditionalInfo, c.Created, c.Duration, c.SourceContainer, c.SourceDescription, c.SourceStagnant, c.PublicID, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Address, c.Status, c.OrganizationID, c.SourceGutter, c.H3cell, c.AddressCountry, c.AddressPlace, c.AddressPostcode, c.AddressRegion, c.AddressStreet, c.IsLocationBackyard, c.IsLocationFrontyard, c.IsLocationGarden, c.IsLocationOther, c.IsLocationPool, c.MapZoom, c.TodEarly, c.TodDay, c.TodEvening, c.TodNight, c.LatlngAccuracyType, c.LatlngAccuracyValue, c.ReporterContactConsent, c.Location,
|
||||
c.ID, c.AdditionalInfo, c.Created, c.Duration, c.SourceContainer, c.SourceDescription, c.SourceStagnant, c.PublicID, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Address, c.Status, c.OrganizationID, c.SourceGutter, c.H3cell, c.AddressCountry, c.AddressPlace, c.AddressPostcode, c.AddressRegion, c.AddressStreet, c.IsLocationBackyard, c.IsLocationFrontyard, c.IsLocationGarden, c.IsLocationOther, c.IsLocationPool, c.MapZoom, c.TodEarly, c.TodDay, c.TodEvening, c.TodNight, c.LatlngAccuracyType, c.LatlngAccuracyValue, c.ReporterContactConsent, c.Location, c.AddressNumber,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -321,6 +321,15 @@ var PublicreportPools = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
AddressNumber: column{
|
||||
Name: "address_number",
|
||||
DBType: "text",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: publicreportPoolIndexes{
|
||||
PoolPkey: index{
|
||||
|
|
@ -420,11 +429,12 @@ type publicreportPoolColumns struct {
|
|||
IsReporterOwner column
|
||||
ReporterContactConsent column
|
||||
Location column
|
||||
AddressNumber column
|
||||
}
|
||||
|
||||
func (c publicreportPoolColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ID, c.AccessComments, c.AccessGate, c.AccessFence, c.AccessLocked, c.AccessDog, c.AccessOther, c.Address, c.AddressCountry, c.AddressPostCode, c.AddressPlace, c.AddressStreet, c.AddressRegion, c.Comments, c.Created, c.H3cell, c.HasAdult, c.HasLarvae, c.HasPupae, c.MapZoom, c.OwnerEmail, c.OwnerName, c.OwnerPhone, c.PublicID, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Status, c.OrganizationID, c.HasBackyardPermission, c.IsReporterConfidential, c.IsReporterOwner, c.ReporterContactConsent, c.Location,
|
||||
c.ID, c.AccessComments, c.AccessGate, c.AccessFence, c.AccessLocked, c.AccessDog, c.AccessOther, c.Address, c.AddressCountry, c.AddressPostCode, c.AddressPlace, c.AddressStreet, c.AddressRegion, c.Comments, c.Created, c.H3cell, c.HasAdult, c.HasLarvae, c.HasPupae, c.MapZoom, c.OwnerEmail, c.OwnerName, c.OwnerPhone, c.PublicID, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Status, c.OrganizationID, c.HasBackyardPermission, c.IsReporterConfidential, c.IsReporterOwner, c.ReporterContactConsent, c.Location, c.AddressNumber,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
12
db/migrations/00094_publicreport_address_number.sql
Normal file
12
db/migrations/00094_publicreport_address_number.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- +goose Up
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN address_number TEXT;
|
||||
UPDATE publicreport.nuisance SET address_number = '';
|
||||
ALTER TABLE publicreport.nuisance ALTER COLUMN address_number SET NOT NULL;
|
||||
|
||||
ALTER TABLE publicreport.pool ADD COLUMN address_number TEXT;
|
||||
UPDATE publicreport.pool SET address_number = '';
|
||||
ALTER TABLE publicreport.pool ALTER COLUMN address_number SET NOT NULL;
|
||||
-- +goose Down
|
||||
ALTER TABLE publicreport.pool DROP COLUMN address_number;
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN address_number;
|
||||
|
||||
|
|
@ -62,6 +62,7 @@ type PublicreportNuisance struct {
|
|||
LatlngAccuracyValue float32 `db:"latlng_accuracy_value" `
|
||||
ReporterContactConsent null.Val[bool] `db:"reporter_contact_consent" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
AddressNumber string `db:"address_number" `
|
||||
|
||||
R publicreportNuisanceR `db:"-" `
|
||||
}
|
||||
|
|
@ -87,7 +88,7 @@ type publicreportNuisanceR struct {
|
|||
func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns {
|
||||
return publicreportNuisanceColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"id", "additional_info", "created", "duration", "source_container", "source_description", "source_stagnant", "public_id", "reporter_email", "reporter_name", "reporter_phone", "address", "status", "organization_id", "source_gutter", "h3cell", "address_country", "address_place", "address_postcode", "address_region", "address_street", "is_location_backyard", "is_location_frontyard", "is_location_garden", "is_location_other", "is_location_pool", "map_zoom", "tod_early", "tod_day", "tod_evening", "tod_night", "latlng_accuracy_type", "latlng_accuracy_value", "reporter_contact_consent", "location",
|
||||
"id", "additional_info", "created", "duration", "source_container", "source_description", "source_stagnant", "public_id", "reporter_email", "reporter_name", "reporter_phone", "address", "status", "organization_id", "source_gutter", "h3cell", "address_country", "address_place", "address_postcode", "address_region", "address_street", "is_location_backyard", "is_location_frontyard", "is_location_garden", "is_location_other", "is_location_pool", "map_zoom", "tod_early", "tod_day", "tod_evening", "tod_night", "latlng_accuracy_type", "latlng_accuracy_value", "reporter_contact_consent", "location", "address_number",
|
||||
).WithParent("publicreport.nuisance"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
|
|
@ -125,6 +126,7 @@ func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns
|
|||
LatlngAccuracyValue: psql.Quote(alias, "latlng_accuracy_value"),
|
||||
ReporterContactConsent: psql.Quote(alias, "reporter_contact_consent"),
|
||||
Location: psql.Quote(alias, "location"),
|
||||
AddressNumber: psql.Quote(alias, "address_number"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -166,6 +168,7 @@ type publicreportNuisanceColumns struct {
|
|||
LatlngAccuracyValue psql.Expression
|
||||
ReporterContactConsent psql.Expression
|
||||
Location psql.Expression
|
||||
AddressNumber psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportNuisanceColumns) Alias() string {
|
||||
|
|
@ -215,10 +218,11 @@ type PublicreportNuisanceSetter struct {
|
|||
LatlngAccuracyValue omit.Val[float32] `db:"latlng_accuracy_value" `
|
||||
ReporterContactConsent omitnull.Val[bool] `db:"reporter_contact_consent" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
AddressNumber omit.Val[string] `db:"address_number" `
|
||||
}
|
||||
|
||||
func (s PublicreportNuisanceSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 35)
|
||||
vals := make([]string, 0, 36)
|
||||
if s.ID.IsValue() {
|
||||
vals = append(vals, "id")
|
||||
}
|
||||
|
|
@ -324,6 +328,9 @@ func (s PublicreportNuisanceSetter) SetColumns() []string {
|
|||
if !s.Location.IsUnset() {
|
||||
vals = append(vals, "location")
|
||||
}
|
||||
if s.AddressNumber.IsValue() {
|
||||
vals = append(vals, "address_number")
|
||||
}
|
||||
return vals
|
||||
}
|
||||
|
||||
|
|
@ -433,6 +440,9 @@ func (s PublicreportNuisanceSetter) Overwrite(t *PublicreportNuisance) {
|
|||
if !s.Location.IsUnset() {
|
||||
t.Location = s.Location.MustGetNull()
|
||||
}
|
||||
if s.AddressNumber.IsValue() {
|
||||
t.AddressNumber = s.AddressNumber.MustGet()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -441,7 +451,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, 35)
|
||||
vals := make([]bob.Expression, 36)
|
||||
if s.ID.IsValue() {
|
||||
vals[0] = psql.Arg(s.ID.MustGet())
|
||||
} else {
|
||||
|
|
@ -652,6 +662,12 @@ func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[34] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.AddressNumber.IsValue() {
|
||||
vals[35] = psql.Arg(s.AddressNumber.MustGet())
|
||||
} else {
|
||||
vals[35] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
|
@ -661,7 +677,7 @@ func (s PublicreportNuisanceSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|||
}
|
||||
|
||||
func (s PublicreportNuisanceSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 35)
|
||||
exprs := make([]bob.Expression, 0, 36)
|
||||
|
||||
if s.ID.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
|
|
@ -908,6 +924,13 @@ func (s PublicreportNuisanceSetter) Expressions(prefix ...string) []bob.Expressi
|
|||
}})
|
||||
}
|
||||
|
||||
if s.AddressNumber.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "address_number")...),
|
||||
psql.Arg(s.AddressNumber),
|
||||
}})
|
||||
}
|
||||
|
||||
return exprs
|
||||
}
|
||||
|
||||
|
|
@ -1520,6 +1543,7 @@ type publicreportNuisanceWhere[Q psql.Filterable] struct {
|
|||
LatlngAccuracyValue psql.WhereMod[Q, float32]
|
||||
ReporterContactConsent psql.WhereNullMod[Q, bool]
|
||||
Location psql.WhereNullMod[Q, string]
|
||||
AddressNumber psql.WhereMod[Q, string]
|
||||
}
|
||||
|
||||
func (publicreportNuisanceWhere[Q]) AliasedAs(alias string) publicreportNuisanceWhere[Q] {
|
||||
|
|
@ -1563,6 +1587,7 @@ func buildPublicreportNuisanceWhere[Q psql.Filterable](cols publicreportNuisance
|
|||
LatlngAccuracyValue: psql.Where[Q, float32](cols.LatlngAccuracyValue),
|
||||
ReporterContactConsent: psql.WhereNull[Q, bool](cols.ReporterContactConsent),
|
||||
Location: psql.WhereNull[Q, string](cols.Location),
|
||||
AddressNumber: psql.Where[Q, string](cols.AddressNumber),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ type PublicreportPool struct {
|
|||
IsReporterOwner bool `db:"is_reporter_owner" `
|
||||
ReporterContactConsent null.Val[bool] `db:"reporter_contact_consent" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
AddressNumber string `db:"address_number" `
|
||||
|
||||
R publicreportPoolR `db:"-" `
|
||||
}
|
||||
|
|
@ -86,7 +87,7 @@ type publicreportPoolR struct {
|
|||
func buildPublicreportPoolColumns(alias string) publicreportPoolColumns {
|
||||
return publicreportPoolColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"id", "access_comments", "access_gate", "access_fence", "access_locked", "access_dog", "access_other", "address", "address_country", "address_post_code", "address_place", "address_street", "address_region", "comments", "created", "h3cell", "has_adult", "has_larvae", "has_pupae", "map_zoom", "owner_email", "owner_name", "owner_phone", "public_id", "reporter_email", "reporter_name", "reporter_phone", "status", "organization_id", "has_backyard_permission", "is_reporter_confidential", "is_reporter_owner", "reporter_contact_consent", "location",
|
||||
"id", "access_comments", "access_gate", "access_fence", "access_locked", "access_dog", "access_other", "address", "address_country", "address_post_code", "address_place", "address_street", "address_region", "comments", "created", "h3cell", "has_adult", "has_larvae", "has_pupae", "map_zoom", "owner_email", "owner_name", "owner_phone", "public_id", "reporter_email", "reporter_name", "reporter_phone", "status", "organization_id", "has_backyard_permission", "is_reporter_confidential", "is_reporter_owner", "reporter_contact_consent", "location", "address_number",
|
||||
).WithParent("publicreport.pool"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
|
|
@ -123,6 +124,7 @@ func buildPublicreportPoolColumns(alias string) publicreportPoolColumns {
|
|||
IsReporterOwner: psql.Quote(alias, "is_reporter_owner"),
|
||||
ReporterContactConsent: psql.Quote(alias, "reporter_contact_consent"),
|
||||
Location: psql.Quote(alias, "location"),
|
||||
AddressNumber: psql.Quote(alias, "address_number"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -163,6 +165,7 @@ type publicreportPoolColumns struct {
|
|||
IsReporterOwner psql.Expression
|
||||
ReporterContactConsent psql.Expression
|
||||
Location psql.Expression
|
||||
AddressNumber psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportPoolColumns) Alias() string {
|
||||
|
|
@ -211,10 +214,11 @@ type PublicreportPoolSetter struct {
|
|||
IsReporterOwner omit.Val[bool] `db:"is_reporter_owner" `
|
||||
ReporterContactConsent omitnull.Val[bool] `db:"reporter_contact_consent" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
AddressNumber omit.Val[string] `db:"address_number" `
|
||||
}
|
||||
|
||||
func (s PublicreportPoolSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 34)
|
||||
vals := make([]string, 0, 35)
|
||||
if s.ID.IsValue() {
|
||||
vals = append(vals, "id")
|
||||
}
|
||||
|
|
@ -317,6 +321,9 @@ func (s PublicreportPoolSetter) SetColumns() []string {
|
|||
if !s.Location.IsUnset() {
|
||||
vals = append(vals, "location")
|
||||
}
|
||||
if s.AddressNumber.IsValue() {
|
||||
vals = append(vals, "address_number")
|
||||
}
|
||||
return vals
|
||||
}
|
||||
|
||||
|
|
@ -423,6 +430,9 @@ func (s PublicreportPoolSetter) Overwrite(t *PublicreportPool) {
|
|||
if !s.Location.IsUnset() {
|
||||
t.Location = s.Location.MustGetNull()
|
||||
}
|
||||
if s.AddressNumber.IsValue() {
|
||||
t.AddressNumber = s.AddressNumber.MustGet()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PublicreportPoolSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -431,7 +441,7 @@ func (s *PublicreportPoolSetter) 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, 34)
|
||||
vals := make([]bob.Expression, 35)
|
||||
if s.ID.IsValue() {
|
||||
vals[0] = psql.Arg(s.ID.MustGet())
|
||||
} else {
|
||||
|
|
@ -636,6 +646,12 @@ func (s *PublicreportPoolSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[33] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.AddressNumber.IsValue() {
|
||||
vals[34] = psql.Arg(s.AddressNumber.MustGet())
|
||||
} else {
|
||||
vals[34] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
|
@ -645,7 +661,7 @@ func (s PublicreportPoolSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|||
}
|
||||
|
||||
func (s PublicreportPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 34)
|
||||
exprs := make([]bob.Expression, 0, 35)
|
||||
|
||||
if s.ID.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
|
|
@ -885,6 +901,13 @@ func (s PublicreportPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
|||
}})
|
||||
}
|
||||
|
||||
if s.AddressNumber.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "address_number")...),
|
||||
psql.Arg(s.AddressNumber),
|
||||
}})
|
||||
}
|
||||
|
||||
return exprs
|
||||
}
|
||||
|
||||
|
|
@ -1496,6 +1519,7 @@ type publicreportPoolWhere[Q psql.Filterable] struct {
|
|||
IsReporterOwner psql.WhereMod[Q, bool]
|
||||
ReporterContactConsent psql.WhereNullMod[Q, bool]
|
||||
Location psql.WhereNullMod[Q, string]
|
||||
AddressNumber psql.WhereMod[Q, string]
|
||||
}
|
||||
|
||||
func (publicreportPoolWhere[Q]) AliasedAs(alias string) publicreportPoolWhere[Q] {
|
||||
|
|
@ -1538,6 +1562,7 @@ func buildPublicreportPoolWhere[Q psql.Filterable](cols publicreportPoolColumns)
|
|||
IsReporterOwner: psql.Where[Q, bool](cols.IsReporterOwner),
|
||||
ReporterContactConsent: psql.WhereNull[Q, bool](cols.ReporterContactConsent),
|
||||
Location: psql.WhereNull[Q, string](cols.Location),
|
||||
AddressNumber: psql.Where[Q, string](cols.AddressNumber),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue