Make lead creation and invalidation for public reports work
The only thing wrong at this point that I can tell is that address aren't being correctly populated when I reverse geocode.
This commit is contained in:
parent
3e1b56a266
commit
e2af49a323
27 changed files with 821 additions and 365 deletions
|
|
@ -31,6 +31,15 @@ var PublicreportReportLocations = Table[
|
|||
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",
|
||||
|
|
@ -58,6 +67,33 @@ var PublicreportReportLocations = Table[
|
|||
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",
|
||||
|
|
@ -82,18 +118,22 @@ var PublicreportReportLocations = Table[
|
|||
}
|
||||
|
||||
type publicreportReportLocationColumns struct {
|
||||
ID column
|
||||
TableName column
|
||||
AddressRaw column
|
||||
Created column
|
||||
Location column
|
||||
PublicID column
|
||||
Status column
|
||||
ID column
|
||||
TableName column
|
||||
AddressID column
|
||||
AddressRaw column
|
||||
Created column
|
||||
Location column
|
||||
LocationLatitude column
|
||||
LocationLongitude column
|
||||
OrganizationID column
|
||||
PublicID column
|
||||
Status column
|
||||
}
|
||||
|
||||
func (c publicreportReportLocationColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ID, c.TableName, c.AddressRaw, c.Created, c.Location, c.PublicID, c.Status,
|
||||
c.ID, c.TableName, c.AddressID, c.AddressRaw, c.Created, c.Location, c.LocationLatitude, c.LocationLongitude, c.OrganizationID, c.PublicID, c.Status,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1294,12 +1294,18 @@ func (e *Imagedatatype) Scan(value any) error {
|
|||
|
||||
// Enum values for Leadtype
|
||||
const (
|
||||
LeadtypeGreenPool Leadtype = "green-pool"
|
||||
LeadtypeUnknown Leadtype = "unknown"
|
||||
LeadtypeGreenPool Leadtype = "green-pool"
|
||||
LeadtypePublicreportNuisance Leadtype = "publicreport-nuisance"
|
||||
LeadtypePublicreportWater Leadtype = "publicreport-water"
|
||||
)
|
||||
|
||||
func AllLeadtype() []Leadtype {
|
||||
return []Leadtype{
|
||||
LeadtypeUnknown,
|
||||
LeadtypeGreenPool,
|
||||
LeadtypePublicreportNuisance,
|
||||
LeadtypePublicreportWater,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1311,7 +1317,10 @@ func (e Leadtype) String() string {
|
|||
|
||||
func (e Leadtype) Valid() bool {
|
||||
switch e {
|
||||
case LeadtypeGreenPool:
|
||||
case LeadtypeUnknown,
|
||||
LeadtypeGreenPool,
|
||||
LeadtypePublicreportNuisance,
|
||||
LeadtypePublicreportWater:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
|
|
|
|||
72
db/migrations/00106_publicreport_location_org_id.sql
Normal file
72
db/migrations/00106_publicreport_location_org_id.sql
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
-- +goose Up
|
||||
DROP VIEW publicreport.report_location;
|
||||
CREATE VIEW publicreport.report_location AS
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (ORDER BY table_name, public_id) AS id,
|
||||
table_name,
|
||||
address_id,
|
||||
address_raw,
|
||||
created,
|
||||
location,
|
||||
location_latitude,
|
||||
location_longitude,
|
||||
organization_id,
|
||||
public_id,
|
||||
status
|
||||
FROM (
|
||||
SELECT
|
||||
'nuisance' AS table_name,
|
||||
address_id,
|
||||
address_raw,
|
||||
created,
|
||||
location,
|
||||
ST_X(location) AS location_longitude,
|
||||
ST_Y(location) AS location_latitude,
|
||||
organization_id,
|
||||
public_id,
|
||||
status
|
||||
FROM publicreport.nuisance
|
||||
UNION
|
||||
SELECT
|
||||
'water' AS table_name,
|
||||
address_id,
|
||||
address_raw,
|
||||
created,
|
||||
location,
|
||||
ST_X(location) AS location_longitude,
|
||||
ST_Y(location) AS location_latitude,
|
||||
organization_id,
|
||||
public_id,
|
||||
status
|
||||
FROM publicreport.water
|
||||
) AS combined_data;
|
||||
-- +goose Down
|
||||
DROP VIEW publicreport.report_location;
|
||||
CREATE VIEW publicreport.report_location AS
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (ORDER BY table_name, public_id) AS id,
|
||||
table_name,
|
||||
address_raw,
|
||||
created,
|
||||
location,
|
||||
public_id,
|
||||
status
|
||||
FROM (
|
||||
SELECT
|
||||
'nuisance' AS table_name,
|
||||
address_raw,
|
||||
created,
|
||||
location,
|
||||
public_id,
|
||||
status
|
||||
FROM publicreport.nuisance
|
||||
UNION
|
||||
SELECT
|
||||
'water' AS table_name,
|
||||
address_raw,
|
||||
created,
|
||||
location,
|
||||
public_id,
|
||||
status
|
||||
FROM publicreport.water
|
||||
) AS combined_data;
|
||||
4
db/migrations/00107_lead_type_publicreport.sql
Normal file
4
db/migrations/00107_lead_type_publicreport.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
-- +goose Up
|
||||
ALTER TYPE LeadType ADD VALUE 'unknown' BEFORE 'green-pool';
|
||||
ALTER TYPE LeadType ADD VALUE 'publicreport-nuisance' AFTER 'green-pool';
|
||||
ALTER TYPE LeadType ADD VALUE 'publicreport-water' AFTER 'publicreport-nuisance';
|
||||
|
|
@ -16,13 +16,17 @@ import (
|
|||
|
||||
// PublicreportReportLocation is an object representing the database table.
|
||||
type PublicreportReportLocation struct {
|
||||
ID null.Val[int64] `db:"id" `
|
||||
TableName null.Val[string] `db:"table_name" `
|
||||
AddressRaw null.Val[string] `db:"address_raw" `
|
||||
Created null.Val[time.Time] `db:"created" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
PublicID null.Val[string] `db:"public_id" `
|
||||
Status null.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
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" `
|
||||
Status null.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
}
|
||||
|
||||
// PublicreportReportLocationSlice is an alias for a slice of pointers to PublicreportReportLocation.
|
||||
|
|
@ -38,29 +42,37 @@ type PublicreportReportLocationsQuery = *psql.ViewQuery[*PublicreportReportLocat
|
|||
func buildPublicreportReportLocationColumns(alias string) publicreportReportLocationColumns {
|
||||
return publicreportReportLocationColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"id", "table_name", "address_raw", "created", "location", "public_id", "status",
|
||||
"id", "table_name", "address_id", "address_raw", "created", "location", "location_latitude", "location_longitude", "organization_id", "public_id", "status",
|
||||
).WithParent("publicreport.report_location"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
TableName: psql.Quote(alias, "table_name"),
|
||||
AddressRaw: psql.Quote(alias, "address_raw"),
|
||||
Created: psql.Quote(alias, "created"),
|
||||
Location: psql.Quote(alias, "location"),
|
||||
PublicID: psql.Quote(alias, "public_id"),
|
||||
Status: psql.Quote(alias, "status"),
|
||||
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"),
|
||||
Status: psql.Quote(alias, "status"),
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportReportLocationColumns struct {
|
||||
expr.ColumnsExpr
|
||||
tableAlias string
|
||||
ID psql.Expression
|
||||
TableName psql.Expression
|
||||
AddressRaw psql.Expression
|
||||
Created psql.Expression
|
||||
Location psql.Expression
|
||||
PublicID psql.Expression
|
||||
Status psql.Expression
|
||||
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
|
||||
Status psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportReportLocationColumns) Alias() string {
|
||||
|
|
@ -96,13 +108,17 @@ func (o PublicreportReportLocationSlice) AfterQueryHook(ctx context.Context, exe
|
|||
}
|
||||
|
||||
type publicreportReportLocationWhere[Q psql.Filterable] struct {
|
||||
ID psql.WhereNullMod[Q, int64]
|
||||
TableName psql.WhereNullMod[Q, string]
|
||||
AddressRaw psql.WhereNullMod[Q, string]
|
||||
Created psql.WhereNullMod[Q, time.Time]
|
||||
Location psql.WhereNullMod[Q, string]
|
||||
PublicID psql.WhereNullMod[Q, string]
|
||||
Status psql.WhereNullMod[Q, enums.PublicreportReportstatustype]
|
||||
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]
|
||||
Status psql.WhereNullMod[Q, enums.PublicreportReportstatustype]
|
||||
}
|
||||
|
||||
func (publicreportReportLocationWhere[Q]) AliasedAs(alias string) publicreportReportLocationWhere[Q] {
|
||||
|
|
@ -111,12 +127,16 @@ func (publicreportReportLocationWhere[Q]) AliasedAs(alias string) publicreportRe
|
|||
|
||||
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),
|
||||
AddressRaw: psql.WhereNull[Q, string](cols.AddressRaw),
|
||||
Created: psql.WhereNull[Q, time.Time](cols.Created),
|
||||
Location: psql.WhereNull[Q, string](cols.Location),
|
||||
PublicID: psql.WhereNull[Q, string](cols.PublicID),
|
||||
Status: psql.WhereNull[Q, enums.PublicreportReportstatustype](cols.Status),
|
||||
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),
|
||||
Status: psql.WhereNull[Q, enums.PublicreportReportstatustype](cols.Status),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue