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:
parent
6945b9f9ed
commit
fde9539191
1 changed files with 5 additions and 4 deletions
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue