Don't attempt to find the parcel if our address ID is nil

That's because the address doesn't have location data, so we can't find
a parcel.
This commit is contained in:
Eli Ribble 2026-04-16 23:54:18 +00:00
parent 6945b9f9ed
commit fde9539191
No known key found for this signature in database

View file

@ -62,6 +62,7 @@ func JobCommit(ctx context.Context, txn bob.Executor, file_id int32) error {
}
for _, row := range rows {
var a *types.Address
var parcel *models.Parcel
if row.AddressID.IsValue() {
var ok bool
a, ok = addresses[row.AddressID.MustGet()]
@ -69,6 +70,10 @@ func JobCommit(ctx context.Context, txn bob.Executor, file_id int32) error {
log.Error().Int32("id", row.AddressID.MustGet()).Msg("address is missing")
continue
}
parcel, err = geocode.GetParcel(ctx, txn, *a)
if err != nil {
return fmt.Errorf("get parcel: %w", err)
}
} else {
a = &types.Address{
Country: "usa",
@ -80,10 +85,6 @@ func JobCommit(ctx context.Context, txn bob.Executor, file_id int32) error {
Unit: "",
}
}
parcel, err := geocode.GetParcel(ctx, txn, *a)
if err != nil {
return fmt.Errorf("get parcel: %w", err)
}
var site *models.Site
site, err = models.Sites.Query(
models.SelectWhere.Sites.AddressID.EQ(*a.ID),