Don't bail on district match early, check address

This is the other half of doing proper district match via raw address -
we have to use the address if available for looking up a district.
This commit is contained in:
Eli Ribble 2026-04-29 15:01:35 +00:00
parent 524353bfa1
commit 2fbceb11e3
No known key found for this signature in database
3 changed files with 35 additions and 14 deletions

View file

@ -45,3 +45,21 @@ func AddressFromComplianceReportRequestID(ctx context.Context, public_id string)
}
return row, nil
}
func AddressLocation(ctx context.Context, address *models.Address) (*types.Location, error) {
if address == nil {
return nil, fmt.Errorf("nil address")
}
row, err := bob.One(ctx, db.PGInstance.BobDB, psql.Select(
sm.Columns(
models.Addresses.Columns.LocationLatitude.As("latitude"),
models.Addresses.Columns.LocationLongitude.As("longitude"),
),
sm.From(models.Addresses.NameAs()),
sm.Where(models.Addresses.Columns.ID.EQ(psql.Arg(address.ID))),
), scan.StructMapper[*types.Location]())
if err != nil {
return nil, fmt.Errorf("query address: %w", err)
}
return row, nil
}