Fix populating water report from ID, make ContactSimple
ContactSimple is the replacement for ContactReporter, which was the simplified form of a contact from a report. I made the name more generic and use it in the general report structures for consistency.
This commit is contained in:
parent
75d0283453
commit
5e103f46a0
14 changed files with 103 additions and 108 deletions
|
|
@ -38,15 +38,20 @@ func ByIDNuisance(ctx context.Context, public_id string, is_public bool) (*types
|
|||
}
|
||||
return nuisance(ctx, public_id, *report)
|
||||
}
|
||||
func ByIDWater(ctx context.Context, public_id string, is_public bool) (*types.PublicReportWater, error) {
|
||||
func ByIDWater(ctx context.Context, public_id string, is_public bool) (types.PublicReportWater, error) {
|
||||
report, err := byID(ctx, public_id, is_public)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("base report byid: %w", err)
|
||||
return types.PublicReportWater{}, fmt.Errorf("base report byid: %w", err)
|
||||
}
|
||||
if report == nil {
|
||||
return nil, nil
|
||||
return types.PublicReportWater{}, nil
|
||||
}
|
||||
return water(ctx, public_id, *report)
|
||||
txn := db.PGInstance.PGXPool
|
||||
water, err := querypublicreport.WaterFromReportID(ctx, txn, int64(report.ID))
|
||||
if err != nil {
|
||||
return types.PublicReportWater{}, fmt.Errorf("water from report id %d: %w", report.ID, err)
|
||||
}
|
||||
return types.PublicReportWaterFromModel(*report, water), nil
|
||||
}
|
||||
func UnreviewedForOrganization(ctx context.Context, txn db.Ex, org_id int64, is_public bool) ([]types.PublicReport, error) {
|
||||
reports, err := querypublicreport.ReportsUnreviewedForOrganization(ctx, txn, org_id)
|
||||
|
|
@ -143,10 +148,10 @@ func reportQueryToRows(ctx context.Context, reports []modelpublicreport.Report,
|
|||
DistrictID: &row.OrganizationID,
|
||||
District: nil,
|
||||
PublicID: row.PublicID,
|
||||
Reporter: types.ContactReporter{
|
||||
Reporter: types.ContactSimple{
|
||||
Email: row.ReporterEmail,
|
||||
Name: row.ReporterName,
|
||||
Phone: types.PhoneReporter{
|
||||
Phone: types.PhoneSimple{
|
||||
CanSMS: row.ReporterPhoneCanSms,
|
||||
Number: row.ReporterPhone,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue