Rework publicreport addressing
This adds the ability to link a proper address in the database to the report and harmonizes the field names with the address table. It also migrates away from mapbox entirely. And I fixed the "pool" naming for the publicreports, which are supposed to be the more generic 'water'.
This commit is contained in:
parent
884634a2d7
commit
e932c2c473
60 changed files with 4511 additions and 5072 deletions
|
|
@ -1,112 +0,0 @@
|
|||
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package sql
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
"io"
|
||||
"iter"
|
||||
"time"
|
||||
|
||||
"github.com/Gleipnir-Technology/bob"
|
||||
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
||||
"github.com/Gleipnir-Technology/bob/dialect/psql/dialect"
|
||||
"github.com/Gleipnir-Technology/bob/orm"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/google/uuid"
|
||||
"github.com/stephenafamo/scan"
|
||||
)
|
||||
|
||||
//go:embed publicreport_image_with_json_by_pool_id.bob.sql
|
||||
var formattedQueries_publicreport_image_with_json_by_pool_id string
|
||||
|
||||
var publicreportImageWithJSONByPoolIDSQL = formattedQueries_publicreport_image_with_json_by_pool_id[171:975]
|
||||
|
||||
type PublicreportImageWithJSONByPoolIDQuery = orm.ModQuery[*dialect.SelectQuery, publicreportImageWithJSONByPoolID, PublicreportImageWithJSONByPoolIDRow, []PublicreportImageWithJSONByPoolIDRow, publicreportImageWithJSONByPoolIDTransformer]
|
||||
|
||||
func PublicreportImageWithJSONByPoolID(PoolID int32) *PublicreportImageWithJSONByPoolIDQuery {
|
||||
var expressionTypArgs publicreportImageWithJSONByPoolID
|
||||
|
||||
expressionTypArgs.PoolID = psql.Arg(PoolID)
|
||||
|
||||
return &PublicreportImageWithJSONByPoolIDQuery{
|
||||
Query: orm.Query[publicreportImageWithJSONByPoolID, PublicreportImageWithJSONByPoolIDRow, []PublicreportImageWithJSONByPoolIDRow, publicreportImageWithJSONByPoolIDTransformer]{
|
||||
ExecQuery: orm.ExecQuery[publicreportImageWithJSONByPoolID]{
|
||||
BaseQuery: bob.BaseQuery[publicreportImageWithJSONByPoolID]{
|
||||
Expression: expressionTypArgs,
|
||||
Dialect: dialect.Dialect,
|
||||
QueryType: bob.QueryTypeSelect,
|
||||
},
|
||||
},
|
||||
Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (PublicreportImageWithJSONByPoolIDRow, error)) {
|
||||
return func(row *scan.Row) (any, error) {
|
||||
var t PublicreportImageWithJSONByPoolIDRow
|
||||
row.ScheduleScanByIndex(0, &t.ID)
|
||||
row.ScheduleScanByIndex(1, &t.ContentType)
|
||||
row.ScheduleScanByIndex(2, &t.Created)
|
||||
row.ScheduleScanByIndex(3, &t.Location)
|
||||
row.ScheduleScanByIndex(4, &t.LocationJSON)
|
||||
row.ScheduleScanByIndex(5, &t.ResolutionX)
|
||||
row.ScheduleScanByIndex(6, &t.ResolutionY)
|
||||
row.ScheduleScanByIndex(7, &t.StorageUUID)
|
||||
row.ScheduleScanByIndex(8, &t.StorageSize)
|
||||
row.ScheduleScanByIndex(9, &t.UploadedFilename)
|
||||
return &t, nil
|
||||
}, func(v any) (PublicreportImageWithJSONByPoolIDRow, error) {
|
||||
return *(v.(*PublicreportImageWithJSONByPoolIDRow)), nil
|
||||
}
|
||||
},
|
||||
},
|
||||
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
||||
q.AppendSelect(expressionTypArgs.subExpr(9, 565))
|
||||
q.SetTable(expressionTypArgs.subExpr(571, 755))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(763, 803))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type PublicreportImageWithJSONByPoolIDRow = struct {
|
||||
ID int32 `db:"id"`
|
||||
ContentType string `db:"content_type"`
|
||||
Created time.Time `db:"created"`
|
||||
Location null.Val[string] `db:"location"`
|
||||
LocationJSON string `db:"location_json"`
|
||||
ResolutionX int32 `db:"resolution_x"`
|
||||
ResolutionY int32 `db:"resolution_y"`
|
||||
StorageUUID uuid.UUID `db:"storage_uuid"`
|
||||
StorageSize int64 `db:"storage_size"`
|
||||
UploadedFilename string `db:"uploaded_filename"`
|
||||
}
|
||||
|
||||
type publicreportImageWithJSONByPoolIDTransformer = bob.SliceTransformer[PublicreportImageWithJSONByPoolIDRow, []PublicreportImageWithJSONByPoolIDRow]
|
||||
|
||||
type publicreportImageWithJSONByPoolID struct {
|
||||
PoolID bob.Expression
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByPoolID) args() iter.Seq[orm.ArgWithPosition] {
|
||||
return func(yield func(arg orm.ArgWithPosition) bool) {
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "poolID",
|
||||
Start: 801,
|
||||
Stop: 803,
|
||||
Expression: o.PoolID,
|
||||
}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByPoolID) raw(from, to int) string {
|
||||
return publicreportImageWithJSONByPoolIDSQL[from:to]
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByPoolID) subExpr(from, to int) bob.Expression {
|
||||
return orm.ArgsToExpression(publicreportImageWithJSONByPoolIDSQL, from, to, o.args())
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByPoolID) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
return o.subExpr(0, len(publicreportImageWithJSONByPoolIDSQL)).WriteSQL(ctx, w, d, start)
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
-- Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
||||
-- This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
-- PublicreportImageWithJSONByPoolID
|
||||
SELECT
|
||||
"publicreport.image"."id" AS "id",
|
||||
"publicreport.image"."content_type" AS "content_type",
|
||||
"publicreport.image"."created" AS "created",
|
||||
"publicreport.image"."location" AS "location",
|
||||
COALESCE(ST_AsGeoJSON("publicreport.image"."location"), '{}') AS "location_json",
|
||||
"publicreport.image"."resolution_x" AS "resolution_x",
|
||||
"publicreport.image"."resolution_y" AS "resolution_y",
|
||||
"publicreport.image"."storage_uuid" AS "storage_uuid",
|
||||
"publicreport.image"."storage_size" AS "storage_size",
|
||||
"publicreport.image"."uploaded_filename" AS "uploaded_filename"
|
||||
FROM "publicreport"."image" AS "publicreport.image"
|
||||
INNER JOIN "publicreport"."pool_image" AS "publicreport.pool_image" ON ("publicreport.image"."id" = "publicreport.pool_image"."image_id")
|
||||
WHERE ("publicreport.pool_image"."pool_id" = $1);
|
||||
112
db/sql/publicreport_image_with_json_by_water_id.bob.go
Normal file
112
db/sql/publicreport_image_with_json_by_water_id.bob.go
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package sql
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
"io"
|
||||
"iter"
|
||||
"time"
|
||||
|
||||
"github.com/Gleipnir-Technology/bob"
|
||||
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
||||
"github.com/Gleipnir-Technology/bob/dialect/psql/dialect"
|
||||
"github.com/Gleipnir-Technology/bob/orm"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/google/uuid"
|
||||
"github.com/stephenafamo/scan"
|
||||
)
|
||||
|
||||
//go:embed publicreport_image_with_json_by_water_id.bob.sql
|
||||
var formattedQueries_publicreport_image_with_json_by_water_id string
|
||||
|
||||
var publicreportImageWithJSONByWaterIDSQL = formattedQueries_publicreport_image_with_json_by_water_id[172:981]
|
||||
|
||||
type PublicreportImageWithJSONByWaterIDQuery = orm.ModQuery[*dialect.SelectQuery, publicreportImageWithJSONByWaterID, PublicreportImageWithJSONByWaterIDRow, []PublicreportImageWithJSONByWaterIDRow, publicreportImageWithJSONByWaterIDTransformer]
|
||||
|
||||
func PublicreportImageWithJSONByWaterID(WaterID int32) *PublicreportImageWithJSONByWaterIDQuery {
|
||||
var expressionTypArgs publicreportImageWithJSONByWaterID
|
||||
|
||||
expressionTypArgs.WaterID = psql.Arg(WaterID)
|
||||
|
||||
return &PublicreportImageWithJSONByWaterIDQuery{
|
||||
Query: orm.Query[publicreportImageWithJSONByWaterID, PublicreportImageWithJSONByWaterIDRow, []PublicreportImageWithJSONByWaterIDRow, publicreportImageWithJSONByWaterIDTransformer]{
|
||||
ExecQuery: orm.ExecQuery[publicreportImageWithJSONByWaterID]{
|
||||
BaseQuery: bob.BaseQuery[publicreportImageWithJSONByWaterID]{
|
||||
Expression: expressionTypArgs,
|
||||
Dialect: dialect.Dialect,
|
||||
QueryType: bob.QueryTypeSelect,
|
||||
},
|
||||
},
|
||||
Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (PublicreportImageWithJSONByWaterIDRow, error)) {
|
||||
return func(row *scan.Row) (any, error) {
|
||||
var t PublicreportImageWithJSONByWaterIDRow
|
||||
row.ScheduleScanByIndex(0, &t.ID)
|
||||
row.ScheduleScanByIndex(1, &t.ContentType)
|
||||
row.ScheduleScanByIndex(2, &t.Created)
|
||||
row.ScheduleScanByIndex(3, &t.Location)
|
||||
row.ScheduleScanByIndex(4, &t.LocationJSON)
|
||||
row.ScheduleScanByIndex(5, &t.ResolutionX)
|
||||
row.ScheduleScanByIndex(6, &t.ResolutionY)
|
||||
row.ScheduleScanByIndex(7, &t.StorageUUID)
|
||||
row.ScheduleScanByIndex(8, &t.StorageSize)
|
||||
row.ScheduleScanByIndex(9, &t.UploadedFilename)
|
||||
return &t, nil
|
||||
}, func(v any) (PublicreportImageWithJSONByWaterIDRow, error) {
|
||||
return *(v.(*PublicreportImageWithJSONByWaterIDRow)), nil
|
||||
}
|
||||
},
|
||||
},
|
||||
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
||||
q.AppendSelect(expressionTypArgs.subExpr(9, 565))
|
||||
q.SetTable(expressionTypArgs.subExpr(571, 758))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(766, 808))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type PublicreportImageWithJSONByWaterIDRow = struct {
|
||||
ID int32 `db:"id"`
|
||||
ContentType string `db:"content_type"`
|
||||
Created time.Time `db:"created"`
|
||||
Location null.Val[string] `db:"location"`
|
||||
LocationJSON string `db:"location_json"`
|
||||
ResolutionX int32 `db:"resolution_x"`
|
||||
ResolutionY int32 `db:"resolution_y"`
|
||||
StorageUUID uuid.UUID `db:"storage_uuid"`
|
||||
StorageSize int64 `db:"storage_size"`
|
||||
UploadedFilename string `db:"uploaded_filename"`
|
||||
}
|
||||
|
||||
type publicreportImageWithJSONByWaterIDTransformer = bob.SliceTransformer[PublicreportImageWithJSONByWaterIDRow, []PublicreportImageWithJSONByWaterIDRow]
|
||||
|
||||
type publicreportImageWithJSONByWaterID struct {
|
||||
WaterID bob.Expression
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByWaterID) args() iter.Seq[orm.ArgWithPosition] {
|
||||
return func(yield func(arg orm.ArgWithPosition) bool) {
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "waterID",
|
||||
Start: 806,
|
||||
Stop: 808,
|
||||
Expression: o.WaterID,
|
||||
}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByWaterID) raw(from, to int) string {
|
||||
return publicreportImageWithJSONByWaterIDSQL[from:to]
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByWaterID) subExpr(from, to int) bob.Expression {
|
||||
return orm.ArgsToExpression(publicreportImageWithJSONByWaterIDSQL, from, to, o.args())
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByWaterID) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
return o.subExpr(0, len(publicreportImageWithJSONByWaterIDSQL)).WriteSQL(ctx, w, d, start)
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
-- PublicreportImageWithJSONByPoolID
|
||||
-- PublicreportImageWithJSONByWaterID
|
||||
SELECT
|
||||
"publicreport.image"."id" AS "id",
|
||||
"publicreport.image"."content_type" AS "content_type",
|
||||
|
|
@ -11,5 +11,5 @@ SELECT
|
|||
"publicreport.image"."storage_size" AS "storage_size",
|
||||
"publicreport.image"."uploaded_filename" AS "uploaded_filename"
|
||||
FROM "publicreport"."image" AS "publicreport.image"
|
||||
INNER JOIN "publicreport"."pool_image" AS "publicreport.pool_image" ON ("publicreport.image"."id" = "publicreport.pool_image"."image_id")
|
||||
WHERE ("publicreport.pool_image"."pool_id" = $1)
|
||||
INNER JOIN "publicreport"."water_image" AS "publicreport.water_image" ON ("publicreport.image"."id" = "publicreport.water_image"."image_id")
|
||||
WHERE ("publicreport.water_image"."water_id" = $1)
|
||||
|
|
@ -21,7 +21,7 @@ import (
|
|||
//go:embed publicreport_publicid_suggestion.bob.sql
|
||||
var formattedQueries_publicreport_publicid_suggestion string
|
||||
|
||||
var publicreportPublicIDSuggestionSQL = formattedQueries_publicreport_publicid_suggestion[168:426]
|
||||
var publicreportPublicIDSuggestionSQL = formattedQueries_publicreport_publicid_suggestion[168:428]
|
||||
|
||||
type PublicreportPublicIDSuggestionQuery = orm.ModQuery[*dialect.SelectQuery, publicreportPublicIDSuggestion, PublicreportPublicIDSuggestionRow, []PublicreportPublicIDSuggestionRow, publicreportPublicIDSuggestionTransformer]
|
||||
|
||||
|
|
@ -60,12 +60,12 @@ func PublicreportPublicIDSuggestion(Arg1 string) *PublicreportPublicIDSuggestion
|
|||
Strategy: "UNION",
|
||||
All: true,
|
||||
Query: bob.BaseQuery[bob.Expression]{
|
||||
Expression: expressionTypArgs.subExpr(129, 237),
|
||||
Expression: expressionTypArgs.subExpr(129, 239),
|
||||
QueryType: bob.QueryTypeSelect,
|
||||
Dialect: dialect.Dialect,
|
||||
},
|
||||
})
|
||||
q.CombinedOrder.AppendOrder(expressionTypArgs.subExpr(249, 258))
|
||||
q.CombinedOrder.AppendOrder(expressionTypArgs.subExpr(251, 260))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
@ -95,8 +95,8 @@ func (o publicreportPublicIDSuggestion) args() iter.Seq[orm.ArgWithPosition] {
|
|||
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "arg1",
|
||||
Start: 235,
|
||||
Stop: 237,
|
||||
Start: 237,
|
||||
Stop: 239,
|
||||
Expression: o.Arg1,
|
||||
}) {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ WHERE
|
|||
UNION ALL
|
||||
|
||||
SELECT
|
||||
'pool' AS table_name,
|
||||
'water' AS table_name,
|
||||
public_id,
|
||||
location
|
||||
FROM
|
||||
publicreport.pool
|
||||
publicreport.water
|
||||
WHERE
|
||||
public_id LIKE $2
|
||||
ORDER BY
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ WHERE
|
|||
UNION ALL
|
||||
|
||||
SELECT
|
||||
'pool' AS table_name,
|
||||
'water' AS table_name,
|
||||
public_id,
|
||||
location
|
||||
FROM
|
||||
publicreport.pool
|
||||
publicreport.water
|
||||
WHERE
|
||||
public_id LIKE $1
|
||||
ORDER BY
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
//go:embed publicreport_publicid_table.bob.sql
|
||||
var formattedQueries_publicreport_publicid_table string
|
||||
|
||||
var publicreportIDTableSQL = formattedQueries_publicreport_publicid_table[157:534]
|
||||
var publicreportIDTableSQL = formattedQueries_publicreport_publicid_table[157:536]
|
||||
|
||||
type PublicreportIDTableQuery = orm.ModQuery[*dialect.SelectQuery, publicreportIDTable, PublicreportIDTableRow, []PublicreportIDTableRow, publicreportIDTableTransformer]
|
||||
|
||||
|
|
@ -51,9 +51,9 @@ func PublicreportIDTable(PublicID string) *PublicreportIDTableQuery {
|
|||
},
|
||||
},
|
||||
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
||||
q.AppendCTE(expressionTypArgs.subExpr(5, 221))
|
||||
q.AppendSelect(expressionTypArgs.subExpr(231, 359))
|
||||
q.SetTable(expressionTypArgs.subExpr(365, 377))
|
||||
q.AppendCTE(expressionTypArgs.subExpr(5, 223))
|
||||
q.AppendSelect(expressionTypArgs.subExpr(233, 361))
|
||||
q.SetTable(expressionTypArgs.subExpr(367, 379))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
@ -83,8 +83,8 @@ func (o publicreportIDTable) args() iter.Seq[orm.ArgWithPosition] {
|
|||
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "publicID",
|
||||
Start: 217,
|
||||
Stop: 219,
|
||||
Start: 219,
|
||||
Stop: 221,
|
||||
Expression: o.PublicID,
|
||||
}) {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ WITH found_tables AS (
|
|||
UNION ALL
|
||||
|
||||
SELECT
|
||||
'pool' as table_name,
|
||||
'water' as table_name,
|
||||
id
|
||||
FROM publicreport.pool
|
||||
FROM publicreport.water
|
||||
WHERE public_id = $2
|
||||
)
|
||||
SELECT
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ WITH found_tables AS (
|
|||
UNION ALL
|
||||
|
||||
SELECT
|
||||
'pool' as table_name,
|
||||
'water' as table_name,
|
||||
id
|
||||
FROM publicreport.pool
|
||||
FROM publicreport.water
|
||||
WHERE public_id = $1
|
||||
)
|
||||
SELECT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue