Initial creation of endpoint to send messages to public reporters
This commit is contained in:
parent
9707e8793b
commit
cc95c38ab5
12 changed files with 240 additions and 20 deletions
|
|
@ -103,6 +103,24 @@ var PublicreportReportLocations = Table[
|
|||
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",
|
||||
|
|
@ -128,12 +146,14 @@ type publicreportReportLocationColumns struct {
|
|||
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.Status,
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
90
db/migrations/00109_publicreport_reporter_contact.sql
Normal file
90
db/migrations/00109_publicreport_reporter_contact.sql
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
-- +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,
|
||||
reporter_email,
|
||||
reporter_phone,
|
||||
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,
|
||||
reporter_email,
|
||||
reporter_phone,
|
||||
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,
|
||||
reporter_email,
|
||||
reporter_phone,
|
||||
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_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;
|
||||
|
|
@ -26,6 +26,8 @@ type PublicreportReportLocation struct {
|
|||
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" `
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +44,7 @@ type PublicreportReportLocationsQuery = *psql.ViewQuery[*PublicreportReportLocat
|
|||
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", "status",
|
||||
"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"),
|
||||
|
|
@ -55,6 +57,8 @@ func buildPublicreportReportLocationColumns(alias string) publicreportReportLoca
|
|||
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"),
|
||||
}
|
||||
}
|
||||
|
|
@ -72,6 +76,8 @@ type publicreportReportLocationColumns struct {
|
|||
LocationLongitude psql.Expression
|
||||
OrganizationID psql.Expression
|
||||
PublicID psql.Expression
|
||||
ReporterEmail psql.Expression
|
||||
ReporterPhone psql.Expression
|
||||
Status psql.Expression
|
||||
}
|
||||
|
||||
|
|
@ -118,6 +124,8 @@ type publicreportReportLocationWhere[Q psql.Filterable] struct {
|
|||
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]
|
||||
}
|
||||
|
||||
|
|
@ -137,6 +145,8 @@ func buildPublicreportReportLocationWhere[Q psql.Filterable](cols publicreportRe
|
|||
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