Remove report_location view, add lat lng to report table
This commit is contained in:
parent
341c3ef6b9
commit
21e8b9880d
9 changed files with 57 additions and 358 deletions
|
|
@ -240,6 +240,24 @@ var PublicreportReports = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
LocationLatitude: column{
|
||||
Name: "location_latitude",
|
||||
DBType: "double precision",
|
||||
Default: "GENERATED",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: true,
|
||||
AutoIncr: false,
|
||||
},
|
||||
LocationLongitude: column{
|
||||
Name: "location_longitude",
|
||||
DBType: "double precision",
|
||||
Default: "GENERATED",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: true,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: publicreportReportIndexes{
|
||||
ReportPkey: index{
|
||||
|
|
@ -348,11 +366,13 @@ type publicreportReportColumns struct {
|
|||
Reviewed column
|
||||
ReviewerID column
|
||||
Status column
|
||||
LocationLatitude column
|
||||
LocationLongitude column
|
||||
}
|
||||
|
||||
func (c publicreportReportColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.AddressRaw, c.AddressNumber, c.AddressStreet, c.AddressLocality, c.AddressRegion, c.AddressPostalCode, c.AddressCountry, c.AddressID, c.Created, c.Location, c.H3cell, c.ID, c.LatlngAccuracyType, c.LatlngAccuracyValue, c.MapZoom, c.OrganizationID, c.PublicID, c.ReporterName, c.ReporterEmail, c.ReporterPhone, c.ReporterContactConsent, c.ReportType, c.Reviewed, c.ReviewerID, c.Status,
|
||||
c.AddressRaw, c.AddressNumber, c.AddressStreet, c.AddressLocality, c.AddressRegion, c.AddressPostalCode, c.AddressCountry, c.AddressID, c.Created, c.Location, c.H3cell, c.ID, c.LatlngAccuracyType, c.LatlngAccuracyValue, c.MapZoom, c.OrganizationID, c.PublicID, c.ReporterName, c.ReporterEmail, c.ReporterPhone, c.ReporterContactConsent, c.ReportType, c.Reviewed, c.ReviewerID, c.Status, c.LocationLatitude, c.LocationLongitude,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,182 +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 dbinfo
|
||||
|
||||
var PublicreportReportLocations = Table[
|
||||
publicreportReportLocationColumns,
|
||||
publicreportReportLocationIndexes,
|
||||
publicreportReportLocationForeignKeys,
|
||||
publicreportReportLocationUniques,
|
||||
publicreportReportLocationChecks,
|
||||
]{
|
||||
Schema: "publicreport",
|
||||
Name: "report_location",
|
||||
Columns: publicreportReportLocationColumns{
|
||||
ID: column{
|
||||
Name: "id",
|
||||
DBType: "bigint",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
TableName: column{
|
||||
Name: "table_name",
|
||||
DBType: "text",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
AddressID: column{
|
||||
Name: "address_id",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
AddressRaw: column{
|
||||
Name: "address_raw",
|
||||
DBType: "text",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Created: column{
|
||||
Name: "created",
|
||||
DBType: "timestamp without time zone",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Location: column{
|
||||
Name: "location",
|
||||
DBType: "geometry",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
LocationLatitude: column{
|
||||
Name: "location_latitude",
|
||||
DBType: "double precision",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
LocationLongitude: column{
|
||||
Name: "location_longitude",
|
||||
DBType: "double precision",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
OrganizationID: column{
|
||||
Name: "organization_id",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
PublicID: column{
|
||||
Name: "public_id",
|
||||
DBType: "text",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ReporterEmail: column{
|
||||
Name: "reporter_email",
|
||||
DBType: "text",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ReporterPhone: column{
|
||||
Name: "reporter_phone",
|
||||
DBType: "text",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Status: column{
|
||||
Name: "status",
|
||||
DBType: "publicreport.reportstatustype",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
|
||||
Comment: "",
|
||||
}
|
||||
|
||||
type publicreportReportLocationColumns struct {
|
||||
ID column
|
||||
TableName column
|
||||
AddressID column
|
||||
AddressRaw column
|
||||
Created column
|
||||
Location column
|
||||
LocationLatitude column
|
||||
LocationLongitude column
|
||||
OrganizationID column
|
||||
PublicID column
|
||||
ReporterEmail column
|
||||
ReporterPhone column
|
||||
Status column
|
||||
}
|
||||
|
||||
func (c publicreportReportLocationColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ID, c.TableName, c.AddressID, c.AddressRaw, c.Created, c.Location, c.LocationLatitude, c.LocationLongitude, c.OrganizationID, c.PublicID, c.ReporterEmail, c.ReporterPhone, c.Status,
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportReportLocationIndexes struct{}
|
||||
|
||||
func (i publicreportReportLocationIndexes) AsSlice() []index {
|
||||
return []index{}
|
||||
}
|
||||
|
||||
type publicreportReportLocationForeignKeys struct{}
|
||||
|
||||
func (f publicreportReportLocationForeignKeys) AsSlice() []foreignKey {
|
||||
return []foreignKey{}
|
||||
}
|
||||
|
||||
type publicreportReportLocationUniques struct{}
|
||||
|
||||
func (u publicreportReportLocationUniques) AsSlice() []constraint {
|
||||
return []constraint{}
|
||||
}
|
||||
|
||||
type publicreportReportLocationChecks struct{}
|
||||
|
||||
func (c publicreportReportLocationChecks) AsSlice() []check {
|
||||
return []check{}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-- +goose Up
|
||||
DROP VIEW publicreport.report_location;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
-- +goose Up
|
||||
ALTER TABLE publicreport.report ADD COLUMN location_latitude DOUBLE PRECISION GENERATED ALWAYS AS (ST_Y(location)) STORED;
|
||||
ALTER TABLE publicreport.report ADD COLUMN location_longitude DOUBLE PRECISION GENERATED ALWAYS AS (ST_X(location)) STORED;
|
||||
-- +goose Down
|
||||
ALTER TABLE publicreport.report DROP COLUMN location_longitude;
|
||||
ALTER TABLE publicreport.report DROP COLUMN location_latitude;
|
||||
|
|
@ -103,7 +103,6 @@ func Where[Q psql.Filterable]() struct {
|
|||
PublicreportOrganizationReportCounts publicreportOrganizationReportCountWhere[Q]
|
||||
PublicreportReports publicreportReportWhere[Q]
|
||||
PublicreportReportImages publicreportReportImageWhere[Q]
|
||||
PublicreportReportLocations publicreportReportLocationWhere[Q]
|
||||
PublicreportReportLogs publicreportReportLogWhere[Q]
|
||||
PublicreportSubscribeEmails publicreportSubscribeEmailWhere[Q]
|
||||
PublicreportSubscribePhones publicreportSubscribePhoneWhere[Q]
|
||||
|
|
@ -210,7 +209,6 @@ func Where[Q psql.Filterable]() struct {
|
|||
PublicreportOrganizationReportCounts publicreportOrganizationReportCountWhere[Q]
|
||||
PublicreportReports publicreportReportWhere[Q]
|
||||
PublicreportReportImages publicreportReportImageWhere[Q]
|
||||
PublicreportReportLocations publicreportReportLocationWhere[Q]
|
||||
PublicreportReportLogs publicreportReportLogWhere[Q]
|
||||
PublicreportSubscribeEmails publicreportSubscribeEmailWhere[Q]
|
||||
PublicreportSubscribePhones publicreportSubscribePhoneWhere[Q]
|
||||
|
|
@ -316,7 +314,6 @@ func Where[Q psql.Filterable]() struct {
|
|||
PublicreportOrganizationReportCounts: buildPublicreportOrganizationReportCountWhere[Q](PublicreportOrganizationReportCounts.Columns),
|
||||
PublicreportReports: buildPublicreportReportWhere[Q](PublicreportReports.Columns),
|
||||
PublicreportReportImages: buildPublicreportReportImageWhere[Q](PublicreportReportImages.Columns),
|
||||
PublicreportReportLocations: buildPublicreportReportLocationWhere[Q](PublicreportReportLocations.Columns),
|
||||
PublicreportReportLogs: buildPublicreportReportLogWhere[Q](PublicreportReportLogs.Columns),
|
||||
PublicreportSubscribeEmails: buildPublicreportSubscribeEmailWhere[Q](PublicreportSubscribeEmails.Columns),
|
||||
PublicreportSubscribePhones: buildPublicreportSubscribePhoneWhere[Q](PublicreportSubscribePhones.Columns),
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ type PublicreportReport struct {
|
|||
Reviewed null.Val[time.Time] `db:"reviewed" `
|
||||
ReviewerID null.Val[int32] `db:"reviewer_id" `
|
||||
Status enums.PublicreportReportstatustype `db:"status" `
|
||||
LocationLatitude null.Val[float64] `db:"location_latitude,generated" `
|
||||
LocationLongitude null.Val[float64] `db:"location_longitude,generated" `
|
||||
|
||||
R publicreportReportR `db:"-" `
|
||||
}
|
||||
|
|
@ -84,7 +86,7 @@ type publicreportReportR struct {
|
|||
func buildPublicreportReportColumns(alias string) publicreportReportColumns {
|
||||
return publicreportReportColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"address_raw", "address_number", "address_street", "address_locality", "address_region", "address_postal_code", "address_country", "address_id", "created", "location", "h3cell", "id", "latlng_accuracy_type", "latlng_accuracy_value", "map_zoom", "organization_id", "public_id", "reporter_name", "reporter_email", "reporter_phone", "reporter_contact_consent", "report_type", "reviewed", "reviewer_id", "status",
|
||||
"address_raw", "address_number", "address_street", "address_locality", "address_region", "address_postal_code", "address_country", "address_id", "created", "location", "h3cell", "id", "latlng_accuracy_type", "latlng_accuracy_value", "map_zoom", "organization_id", "public_id", "reporter_name", "reporter_email", "reporter_phone", "reporter_contact_consent", "report_type", "reviewed", "reviewer_id", "status", "location_latitude", "location_longitude",
|
||||
).WithParent("publicreport.report"),
|
||||
tableAlias: alias,
|
||||
AddressRaw: psql.Quote(alias, "address_raw"),
|
||||
|
|
@ -112,6 +114,8 @@ func buildPublicreportReportColumns(alias string) publicreportReportColumns {
|
|||
Reviewed: psql.Quote(alias, "reviewed"),
|
||||
ReviewerID: psql.Quote(alias, "reviewer_id"),
|
||||
Status: psql.Quote(alias, "status"),
|
||||
LocationLatitude: psql.Quote(alias, "location_latitude"),
|
||||
LocationLongitude: psql.Quote(alias, "location_longitude"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -143,6 +147,8 @@ type publicreportReportColumns struct {
|
|||
Reviewed psql.Expression
|
||||
ReviewerID psql.Expression
|
||||
Status psql.Expression
|
||||
LocationLatitude psql.Expression
|
||||
LocationLongitude psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportReportColumns) Alias() string {
|
||||
|
|
@ -1863,6 +1869,8 @@ type publicreportReportWhere[Q psql.Filterable] struct {
|
|||
Reviewed psql.WhereNullMod[Q, time.Time]
|
||||
ReviewerID psql.WhereNullMod[Q, int32]
|
||||
Status psql.WhereMod[Q, enums.PublicreportReportstatustype]
|
||||
LocationLatitude psql.WhereNullMod[Q, float64]
|
||||
LocationLongitude psql.WhereNullMod[Q, float64]
|
||||
}
|
||||
|
||||
func (publicreportReportWhere[Q]) AliasedAs(alias string) publicreportReportWhere[Q] {
|
||||
|
|
@ -1896,6 +1904,8 @@ func buildPublicreportReportWhere[Q psql.Filterable](cols publicreportReportColu
|
|||
Reviewed: psql.WhereNull[Q, time.Time](cols.Reviewed),
|
||||
ReviewerID: psql.WhereNull[Q, int32](cols.ReviewerID),
|
||||
Status: psql.Where[Q, enums.PublicreportReportstatustype](cols.Status),
|
||||
LocationLatitude: psql.WhereNull[Q, float64](cols.LocationLatitude),
|
||||
LocationLongitude: psql.WhereNull[Q, float64](cols.LocationLongitude),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,152 +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 models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/Gleipnir-Technology/bob"
|
||||
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
||||
"github.com/Gleipnir-Technology/bob/expr"
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
"github.com/aarondl/opt/null"
|
||||
)
|
||||
|
||||
// PublicreportReportLocation is an object representing the database table.
|
||||
type PublicreportReportLocation struct {
|
||||
ID null.Val[int64] `db:"id" `
|
||||
TableName null.Val[string] `db:"table_name" `
|
||||
AddressID null.Val[int32] `db:"address_id" `
|
||||
AddressRaw null.Val[string] `db:"address_raw" `
|
||||
Created null.Val[time.Time] `db:"created" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
LocationLatitude null.Val[float64] `db:"location_latitude" `
|
||||
LocationLongitude null.Val[float64] `db:"location_longitude" `
|
||||
OrganizationID null.Val[int32] `db:"organization_id" `
|
||||
PublicID null.Val[string] `db:"public_id" `
|
||||
ReporterEmail null.Val[string] `db:"reporter_email" `
|
||||
ReporterPhone null.Val[string] `db:"reporter_phone" `
|
||||
Status null.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
}
|
||||
|
||||
// PublicreportReportLocationSlice is an alias for a slice of pointers to PublicreportReportLocation.
|
||||
// This should almost always be used instead of []*PublicreportReportLocation.
|
||||
type PublicreportReportLocationSlice []*PublicreportReportLocation
|
||||
|
||||
// PublicreportReportLocations contains methods to work with the report_location view
|
||||
var PublicreportReportLocations = psql.NewViewx[*PublicreportReportLocation, PublicreportReportLocationSlice]("publicreport", "report_location", buildPublicreportReportLocationColumns("publicreport.report_location"))
|
||||
|
||||
// PublicreportReportLocationsQuery is a query on the report_location view
|
||||
type PublicreportReportLocationsQuery = *psql.ViewQuery[*PublicreportReportLocation, PublicreportReportLocationSlice]
|
||||
|
||||
func buildPublicreportReportLocationColumns(alias string) publicreportReportLocationColumns {
|
||||
return publicreportReportLocationColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"id", "table_name", "address_id", "address_raw", "created", "location", "location_latitude", "location_longitude", "organization_id", "public_id", "reporter_email", "reporter_phone", "status",
|
||||
).WithParent("publicreport.report_location"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
TableName: psql.Quote(alias, "table_name"),
|
||||
AddressID: psql.Quote(alias, "address_id"),
|
||||
AddressRaw: psql.Quote(alias, "address_raw"),
|
||||
Created: psql.Quote(alias, "created"),
|
||||
Location: psql.Quote(alias, "location"),
|
||||
LocationLatitude: psql.Quote(alias, "location_latitude"),
|
||||
LocationLongitude: psql.Quote(alias, "location_longitude"),
|
||||
OrganizationID: psql.Quote(alias, "organization_id"),
|
||||
PublicID: psql.Quote(alias, "public_id"),
|
||||
ReporterEmail: psql.Quote(alias, "reporter_email"),
|
||||
ReporterPhone: psql.Quote(alias, "reporter_phone"),
|
||||
Status: psql.Quote(alias, "status"),
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportReportLocationColumns struct {
|
||||
expr.ColumnsExpr
|
||||
tableAlias string
|
||||
ID psql.Expression
|
||||
TableName psql.Expression
|
||||
AddressID psql.Expression
|
||||
AddressRaw psql.Expression
|
||||
Created psql.Expression
|
||||
Location psql.Expression
|
||||
LocationLatitude psql.Expression
|
||||
LocationLongitude psql.Expression
|
||||
OrganizationID psql.Expression
|
||||
PublicID psql.Expression
|
||||
ReporterEmail psql.Expression
|
||||
ReporterPhone psql.Expression
|
||||
Status psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportReportLocationColumns) Alias() string {
|
||||
return c.tableAlias
|
||||
}
|
||||
|
||||
func (publicreportReportLocationColumns) AliasedAs(alias string) publicreportReportLocationColumns {
|
||||
return buildPublicreportReportLocationColumns(alias)
|
||||
}
|
||||
|
||||
// AfterQueryHook is called after PublicreportReportLocation is retrieved from the database
|
||||
func (o *PublicreportReportLocation) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
||||
var err error
|
||||
|
||||
switch queryType {
|
||||
case bob.QueryTypeSelect:
|
||||
ctx, err = PublicreportReportLocations.AfterSelectHooks.RunHooks(ctx, exec, PublicreportReportLocationSlice{o})
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// AfterQueryHook is called after PublicreportReportLocationSlice is retrieved from the database
|
||||
func (o PublicreportReportLocationSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
||||
var err error
|
||||
|
||||
switch queryType {
|
||||
case bob.QueryTypeSelect:
|
||||
ctx, err = PublicreportReportLocations.AfterSelectHooks.RunHooks(ctx, exec, o)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type publicreportReportLocationWhere[Q psql.Filterable] struct {
|
||||
ID psql.WhereNullMod[Q, int64]
|
||||
TableName psql.WhereNullMod[Q, string]
|
||||
AddressID psql.WhereNullMod[Q, int32]
|
||||
AddressRaw psql.WhereNullMod[Q, string]
|
||||
Created psql.WhereNullMod[Q, time.Time]
|
||||
Location psql.WhereNullMod[Q, string]
|
||||
LocationLatitude psql.WhereNullMod[Q, float64]
|
||||
LocationLongitude psql.WhereNullMod[Q, float64]
|
||||
OrganizationID psql.WhereNullMod[Q, int32]
|
||||
PublicID psql.WhereNullMod[Q, string]
|
||||
ReporterEmail psql.WhereNullMod[Q, string]
|
||||
ReporterPhone psql.WhereNullMod[Q, string]
|
||||
Status psql.WhereNullMod[Q, enums.PublicreportReportstatustype]
|
||||
}
|
||||
|
||||
func (publicreportReportLocationWhere[Q]) AliasedAs(alias string) publicreportReportLocationWhere[Q] {
|
||||
return buildPublicreportReportLocationWhere[Q](buildPublicreportReportLocationColumns(alias))
|
||||
}
|
||||
|
||||
func buildPublicreportReportLocationWhere[Q psql.Filterable](cols publicreportReportLocationColumns) publicreportReportLocationWhere[Q] {
|
||||
return publicreportReportLocationWhere[Q]{
|
||||
ID: psql.WhereNull[Q, int64](cols.ID),
|
||||
TableName: psql.WhereNull[Q, string](cols.TableName),
|
||||
AddressID: psql.WhereNull[Q, int32](cols.AddressID),
|
||||
AddressRaw: psql.WhereNull[Q, string](cols.AddressRaw),
|
||||
Created: psql.WhereNull[Q, time.Time](cols.Created),
|
||||
Location: psql.WhereNull[Q, string](cols.Location),
|
||||
LocationLatitude: psql.WhereNull[Q, float64](cols.LocationLatitude),
|
||||
LocationLongitude: psql.WhereNull[Q, float64](cols.LocationLongitude),
|
||||
OrganizationID: psql.WhereNull[Q, int32](cols.OrganizationID),
|
||||
PublicID: psql.WhereNull[Q, string](cols.PublicID),
|
||||
ReporterEmail: psql.WhereNull[Q, string](cols.ReporterEmail),
|
||||
ReporterPhone: psql.WhereNull[Q, string](cols.ReporterPhone),
|
||||
Status: psql.WhereNull[Q, enums.PublicreportReportstatustype](cols.Status),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue