Avoid making the images list null if there are no images
This commit is contained in:
parent
66e122f7e7
commit
70ebfa8ee0
2 changed files with 12 additions and 2 deletions
|
|
@ -93,7 +93,12 @@ func NuisanceReportForOrganization(ctx context.Context, org_id int32) ([]Nuisanc
|
||||||
return nil, fmt.Errorf("images for report: %w", err)
|
return nil, fmt.Errorf("images for report: %w", err)
|
||||||
}
|
}
|
||||||
for i := range reports {
|
for i := range reports {
|
||||||
reports[i].Images = images_by_id[reports[i].ID]
|
images, ok := images_by_id[reports[i].ID]
|
||||||
|
if ok {
|
||||||
|
reports[i].Images = images
|
||||||
|
} else {
|
||||||
|
reports[i].Images = []types.Image{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return reports, nil
|
return reports, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,12 @@ func WaterReportForOrganization(ctx context.Context, org_id int32) ([]Water, err
|
||||||
return nil, fmt.Errorf("images for report: %w", err)
|
return nil, fmt.Errorf("images for report: %w", err)
|
||||||
}
|
}
|
||||||
for i := range reports {
|
for i := range reports {
|
||||||
reports[i].Images = images_by_id[reports[i].ID]
|
images, ok := images_by_id[reports[i].ID]
|
||||||
|
if ok {
|
||||||
|
reports[i].Images = images
|
||||||
|
} else {
|
||||||
|
reports[i].Images = []types.Image{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return reports, nil
|
return reports, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue