diff --git a/platform/publicreport.go b/platform/publicreport.go index 42bdeafe..79f64bb4 100644 --- a/platform/publicreport.go +++ b/platform/publicreport.go @@ -97,9 +97,15 @@ func PublicReportUpdate(ctx context.Context, report_id string, report_setter mod if err != nil { return nil, fmt.Errorf("query report existence: %w", err) } - err = report.Update(ctx, txn, &report_setter) - if err != nil { - return nil, fmt.Errorf("update report: %w", err) + // Avoid attempting to perform an empty update + if report_setter.LatlngAccuracyValue.IsValue() || + report_setter.ReporterEmail.IsValue() || + report_setter.ReporterName.IsValue() || + report_setter.ReporterPhone.IsValue() { + err = report.Update(ctx, txn, &report_setter) + if err != nil { + return nil, fmt.Errorf("update report: %w", err) + } } if address != nil { err = reportUpdateAddress(ctx, txn, report, *address) diff --git a/stadia/response_type.go b/stadia/response_type.go index af1e31dd..831df0d6 100644 --- a/stadia/response_type.go +++ b/stadia/response_type.go @@ -151,3 +151,55 @@ type GeocodeSource struct { Source string `json:"source"` SourceID string `json:"source_id"` } + +func (gf GeocodeFeature) CountryCode() string { + if gf.Properties.CountryCode != "" { + return gf.Properties.CountryCode + } + if gf.Properties.Context.ISO3166A3 != "" { + return gf.Properties.Context.ISO3166A3 + } + if gf.Properties.Context.WhosOnFirst.Country.Abbreviation != "" { + return gf.Properties.Context.WhosOnFirst.Country.Abbreviation + } + return "" +} +func (gf GeocodeFeature) Locality() string { + if gf.Properties.Locality != "" { + return gf.Properties.Locality + } + if gf.Properties.Context.WhosOnFirst.Locality.Name != "" { + return gf.Properties.Context.WhosOnFirst.Locality.Name + } + return "" +} +func (gf GeocodeFeature) Number() string { + return gf.Properties.AddressComponents.Number +} +func (gf GeocodeFeature) PostalCode() string { + if gf.Properties.PostalCode != "" { + return gf.Properties.PostalCode + } + if gf.Properties.AddressComponents.PostalCode != "" { + return gf.Properties.AddressComponents.PostalCode + } + return "" +} +func (gf GeocodeFeature) Region() string { + if gf.Properties.Region != "" { + return gf.Properties.Region + } + if gf.Properties.Context.WhosOnFirst.Region.Name != "" { + return gf.Properties.Context.WhosOnFirst.Region.Name + } + return "" +} +func (gf GeocodeFeature) Street() string { + if gf.Properties.Street != "" { + return gf.Properties.Street + } + if gf.Properties.AddressComponents.Street != "" { + return gf.Properties.AddressComponents.Street + } + return "" +}