From 21e8b9880dcd81504fda92acf51763295f696fcf Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Wed, 18 Mar 2026 18:55:50 +0000 Subject: [PATCH] Remove report_location view, add lat lng to report table --- db/dbinfo/publicreport.report.bob.go | 22 ++- db/dbinfo/publicreport.report_location.bob.go | 182 ------------------ ...0116_drop_publicreport_report_location.sql | 2 + ...17_publicreport_report_location_latlng.sql | 6 + db/models/bob_where.bob.go | 3 - db/models/publicreport.report.bob.go | 12 +- db/models/publicreport.report_location.bob.go | 152 --------------- platform/lead.go | 29 ++- rmo/notification.go | 7 +- 9 files changed, 57 insertions(+), 358 deletions(-) delete mode 100644 db/dbinfo/publicreport.report_location.bob.go create mode 100644 db/migrations/00116_drop_publicreport_report_location.sql create mode 100644 db/migrations/00117_publicreport_report_location_latlng.sql delete mode 100644 db/models/publicreport.report_location.bob.go diff --git a/db/dbinfo/publicreport.report.bob.go b/db/dbinfo/publicreport.report.bob.go index 3e7d8741..5118a777 100644 --- a/db/dbinfo/publicreport.report.bob.go +++ b/db/dbinfo/publicreport.report.bob.go @@ -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, } } diff --git a/db/dbinfo/publicreport.report_location.bob.go b/db/dbinfo/publicreport.report_location.bob.go deleted file mode 100644 index b34724d5..00000000 --- a/db/dbinfo/publicreport.report_location.bob.go +++ /dev/null @@ -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{} -} diff --git a/db/migrations/00116_drop_publicreport_report_location.sql b/db/migrations/00116_drop_publicreport_report_location.sql new file mode 100644 index 00000000..6f880052 --- /dev/null +++ b/db/migrations/00116_drop_publicreport_report_location.sql @@ -0,0 +1,2 @@ +-- +goose Up +DROP VIEW publicreport.report_location; diff --git a/db/migrations/00117_publicreport_report_location_latlng.sql b/db/migrations/00117_publicreport_report_location_latlng.sql new file mode 100644 index 00000000..8c068bb8 --- /dev/null +++ b/db/migrations/00117_publicreport_report_location_latlng.sql @@ -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; diff --git a/db/models/bob_where.bob.go b/db/models/bob_where.bob.go index 42915d22..8ff9be5b 100644 --- a/db/models/bob_where.bob.go +++ b/db/models/bob_where.bob.go @@ -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), diff --git a/db/models/publicreport.report.bob.go b/db/models/publicreport.report.bob.go index 836c7156..4e9321e7 100644 --- a/db/models/publicreport.report.bob.go +++ b/db/models/publicreport.report.bob.go @@ -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), } } diff --git a/db/models/publicreport.report_location.bob.go b/db/models/publicreport.report_location.bob.go deleted file mode 100644 index e01b9b4c..00000000 --- a/db/models/publicreport.report_location.bob.go +++ /dev/null @@ -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), - } -} diff --git a/platform/lead.go b/platform/lead.go index b4f9536f..4fb6777d 100644 --- a/platform/lead.go +++ b/platform/lead.go @@ -73,9 +73,9 @@ func LeadCreateFromPublicreport(ctx context.Context, user User, report_id string return nil, fmt.Errorf("start transaction: %w", err) } - location, err := models.PublicreportReportLocations.Query( - models.SelectWhere.PublicreportReportLocations.PublicID.EQ(report_id), - models.SelectWhere.PublicreportReportLocations.OrganizationID.EQ(user.Organization.ID()), + report, err := models.PublicreportReports.Query( + models.SelectWhere.PublicreportReports.PublicID.EQ(report_id), + models.SelectWhere.PublicreportReports.OrganizationID.EQ(user.Organization.ID()), ).One(ctx, txn) if err != nil { return nil, fmt.Errorf("query report existence: %w", err) @@ -84,26 +84,26 @@ func LeadCreateFromPublicreport(ctx context.Context, user User, report_id string // At this point we have a report. We need to decide where to put it based on either the address or // the location. var site_id int32 - if location.AddressID.IsValue() { - site, err := siteFromAddress(ctx, txn, user, location.AddressID.MustGet()) + if report.AddressID.IsValue() { + site, err := siteFromAddress(ctx, txn, user, report.AddressID.MustGet()) if err != nil { return nil, fmt.Errorf("site from address: %w", err) } site_id = site.ID - } else if location.LocationLatitude.IsValue() && location.LocationLongitude.IsValue() { + } else if report.LocationLatitude.IsValue() && report.LocationLongitude.IsValue() { site, err := siteFromLocation(ctx, txn, user, Location{ - Latitude: location.LocationLatitude.MustGet(), - Longitude: location.LocationLongitude.MustGet(), + Latitude: report.LocationLatitude.MustGet(), + Longitude: report.LocationLongitude.MustGet(), }) if err != nil { return nil, fmt.Errorf("site from address: %w", err) } site_id = site.ID - } else if location.AddressRaw.GetOr("") != "" { + } else if report.AddressRaw != "" { // At this point we don't have an address, and we don't have GPS // We'll try geocoding and creating an address from that. - site, err := siteFromAddressRaw(ctx, txn, user, location.AddressRaw.MustGet()) + site, err := siteFromAddressRaw(ctx, txn, user, report.AddressRaw) if err != nil { return nil, fmt.Errorf("site from address: %w", err) } @@ -115,11 +115,10 @@ func LeadCreateFromPublicreport(ctx context.Context, user User, report_id string } lead_type := enums.LeadtypeUnknown - tablename := location.TableName.MustGet() - switch tablename { - case "nuisance": + switch report.ReportType { + case enums.PublicreportReporttypeNuisance: lead_type = enums.LeadtypePublicreportNuisance - case "water": + case enums.PublicreportReporttypeWater: lead_type = enums.LeadtypePublicreportWater } lead, err := models.Leads.Insert(&models.LeadSetter{ @@ -131,7 +130,7 @@ func LeadCreateFromPublicreport(ctx context.Context, user User, report_id string Type: omit.From(lead_type), }).One(ctx, txn) _, err = psql.Update( - um.Table("publicreport."+tablename), + um.Table(psql.Quote("publicreport", "report")), um.SetCol("reviewed").ToArg(time.Now()), um.SetCol("reviewer_id").ToArg(user.ID), um.SetCol("status").ToArg(enums.PublicreportReportstatustypeReviewed), diff --git a/rmo/notification.go b/rmo/notification.go index cbbcca3f..3cb6fdd2 100644 --- a/rmo/notification.go +++ b/rmo/notification.go @@ -44,8 +44,8 @@ func postRegisterNotifications(w http.ResponseWriter, r *http.Request) { return } defer txn.Rollback(ctx) - location, err := models.PublicreportReportLocations.Query( - models.SelectWhere.PublicreportReportLocations.PublicID.EQ(report_id), + location, err := models.PublicreportReports.Query( + models.SelectWhere.PublicreportReports.PublicID.EQ(report_id), ).One(ctx, db.PGInstance.BobDB) if err != nil { log.Error().Err(err).Msg("Failed to get report location") @@ -53,7 +53,6 @@ func postRegisterNotifications(w http.ResponseWriter, r *http.Request) { return } - tablename := location.TableName.MustGet() org_id := location.OrganizationID.MustGet() e := report.SaveReporter(ctx, txn, report_id, name, email, phone, has_consent) if e != nil { @@ -94,7 +93,7 @@ func postRegisterNotifications(w http.ResponseWriter, r *http.Request) { } } txn.Commit(ctx) - platform.PublicReportReporterUpdated(ctx, org_id, report_id, tablename) + platform.PublicReportReporterUpdated(ctx, org_id, report_id) http.Redirect(w, r, fmt.Sprintf("/register-notifications-complete?report=%s", report_id), http.StatusFound) }